A button loop is a template file construct which allows you to iterate through the collection of buttons that CodeGen has information about.
The definition of the buttons processed in a button loop can come from one of two places. If you are processing based on a UI Toolkit input window definition then by default the collection of buttons is determined by the buttons found in that input window definition. Otherwise the button collection is defined by a configuration file called DefaultButtons.xml, which you will find in the folder that you installed CodeGen into.
Note: Even if you are processing based on a UI Toolkit input window definition, you can chose to ignore the definition of buttons found in the window and use the definitions from DefaultButtons.xml via the –b command line option.
Button loops are delimited by a matching pair of <BUTTON_LOOP> and </BUTTON_LOOP> tags that surround the template code to be inserted for each button. The code between the opening and closing tags of a button loop is repeated for each button in the button collection.
Button loop tokens are tokens that can only be used within a button loop:
There are two types of button loop, multi-line button loops and in-line button loops.
Multi-Line Button Loops
Multi-line button loops occur when the opening and closing button loop tags appear on separate lines in a template file, and delimit one or more entire lines of template code, like this:
Multi-line button loops generate one or more lines of output code for each button that is processed.
In-Line Button Loops
In-line button loops exist when the opening and closing button loop tags appear on the same line in a template file, and delimit part of a line of template code, like this:
[code] <BUTTON_LOOP> code </BUTTON_LOOP> [code]
In-line button loops generate code into the current output line only.
The default buttons are defined in DefaultButtons.xml, as follows:
<Button name="Ok" caption="OK" image="" method="" elb="" quickselect="O" />
<Button name="Cancel" caption="Cancel" image="" method="" elb="" quickselect="C" />
<Button name="Help" caption="Help" image="" method="" elb=""quickselect="H" />
Special Button Processing
When generating application source code, and in particular forms, it is often useful to be able to identify a button as either an "OK" button (which generally saves the data and closes the form) or a "Cancel" button (which closes the form without saving the data). Unfortunately there is no way to easily identify this from information in a UI Toolkit input window script.
CodeGen considers a button to be an "OK" button if the term "OK" appears in either the name or caption of the button.
CodeGen considers a button to be a "Cancel" button if the word "Cancel" appears in the buttons name or caption, or if the word "abandon" appears in the buttons name (UI Toolkit programmers often name the cancel button O_ABANDON).
The status a button as either an OK or Cancel button can be tested with the button loop expressions <IF OKBUTTON> and <IF CANCELBUTTON>.
Copyright © 2018 Synergex International, Inc.