// AutoDeclare.dxl v1.2 - Set or Clear the AutoDeclare_ flag of the DXL interpreter const string c_Version = "AutoDeclare.dxl v1.2" /* AutoDeclare.dxl AutoDeclare.dxl Allows the user to turn ON, turn OFF, or preserve the existing AutoDeclare_ flag of the DOORS environment. This takes affect for all DXL initiated after this one finishes, in the current instance of DOORS. This program has no effect on other instances of DOORS (future or concurrent) and has no effect on on currently running DXL, such as those displaying a Dialog Box. Auto-Declare can be turned OFF by default by inserting the following line of code into one's startup.dxl file, as explained in the DXL manual chapter 'Introduction' section 'Language fundamentals'; or search for 'XFLAGS_'. XFLAGS_ &=~AutoDeclare_ However, that change only takes affect when DOORS starts and doesn't affect the current instance of DOORS. */ /* Revision History v 1.0 07-Jan-26 AutoDeclareSet.dxl by Landale. Replaces AutoDeclareToggle.dxl. Not deployed 1.1 07-Apr-20 Renamed AutoDeclare.dxl. Improved comments and text. Not Deployed 1.2 07-Aug-09 1st Deployment. Adjusted display a little. */ /* Developer's Comments and Opinion By default, Auto-Declare of variables is allowed in DXL. This encourages folks to write DXL that implicitly defines the variables, e.g. "othero = target(lnk)" implicitly defines 'othero' as type 'Object'. Even though there are 3 ('overloaded') versions of the 'target(lnk)' command (Object, string, ModName_), the DXL interpreter defaults to the first one found, in this case 'Object'. That's what it did in v7 of DOORS. In v81 of DOORS, 'target(obj)' defaults to type 'string'. This makes most old Layout DXL obsolete since they were written with Auto-Declare on using that exact code 'othero = target(lnk)' expecting 'othero' to be an 'Object' but now is a 'string', which triggers DXL errors elsewhere in the code. Its this author's opinion that Auto-Declare is a bad feature and should be avoided when developing DXL. Not only for the reason above (new DOORS version obsoletes old DXL), but also because it serves no purpose other than saving a few key strokes, but can cause significant havoc introducing very hard to find 'bugs' into one's program, simply by misspelling a variable. However, since much DXL is written with Auto-Declare on, this program becomes very useful for the DXL developer: she can turn Auto-Declare off when developing scripts and running them, but can turn it on when debugging other folks scripts and when browsing the hierarchy and opening modules that may have Layout or AttrDXL written to demand Auto-Declare on, such as the bulk of Layouts created by the analysis Wizards. */ string HelpText = " " c_Version ": Discussion: DXL Auto-Declare ON allows DXL programmers to implicitly declare their variables. Done = false When ON, Implicit declaration as Boolean allowed based on context. bool Done = false When OFF, Explicit declaration is required. ON is default. OFF is highly recommended for sound theoretical and practical reasons. Search for 'AutoDeclare_' in the DXL manual for how to make OFF the default. This utility lets serious OFF programmers turn it on when they encounter code written with it turned ON (such as Layout Wizard code), and then turn it back OFF when developing code again. >>> " // Note: Extra space here makes dialog easier to read. string Preamble bool AutoIsOn = (XFLAGS_ & AutoDeclare_ != 0) int Response // print "AutoDeclareToggle, XFLAGS, IsOn = \t" XFLAGS_ "\t" AutoIsOn "\n" if (AutoIsOn) { // Currently ON string QueryOptsWhenOn[] = { "Keep ON (May Implicit declare)", // option 0 - "Turn OFF (Must Excplicit declare)", // option 1 - "Cancel. Do not change." // option 2 - } Preamble = HelpText "AutoDeclare is currently ON." Response = query(Preamble, QueryOptsWhenOn) // Prompt user here. } else { // Currently OFF string QueryOptsWhenOff[] = { "Turn ON (May Implicit declare)", // option 0 - "Keep OFF (Must Excplicit declare)", // option 1 - "Cancel. Do not change." // option 2 - } Preamble = HelpText "AutoDeclare is currently OFF." Response = query(Preamble, QueryOptsWhenOff) // Prompt user here. } if (!AutoIsOn and Response == 0) XFLAGS_ |= AutoDeclare_ // Turn it ON elseif( AutoIsOn and Response == 1) XFLAGS_ &=~AutoDeclare_ // Turn it OFF else {} // no change // ---- end file AutoDeclare.dxl ----