Macro Language Reference > Macros > Window > wdb
  
wdb
Description
Makes an invisible call to a dialog box, either to the screen or to a set of named variables which can then be used and manipulated in a script or a further macro. Both forms of wdb are used extensively within scripts.
 
Example 322. Make an invisible call to a nominated dialog box
The macros below are shown as they would appear in a script and will make an 'invisible' call to PTC ALDtypeface name dialog box:
wdb "variable1","variable2","variable3"
tf
Usually, when you enter the tf macro on its own, the typeface name dialog box would appear. This shows the 'short' and 'long' names of the currently-selected typeface, in two edit boxes. When you enter the tf macro immediately after a valid wdb macro, however, the dialog box will not appear and the contents of each edit box are 'pushed' into the variables named by wdb in the order they appear in the dialog box. In this example ^variable1 would receive the font short name, and ^variable2 would receive the font long name. The wdb macro asks for three variables to be filled: but because the typeface name dialog box only contains two edit boxes, ^variable3 remains unaffected, i.e. retains any value it previously had.
 
Example 323. Define a dialog box with the ^wdb variable and macros
The example below shows a simple use of the ^wdb variable, along with condition macros, in a stripped down version of the script used in stuk.3ad to define the search/replace dialog box.
"ts", "320"
$defstr 349,"@/ @|Search / Replace\n"<>
$addstr 349,"--\n"<>
$addstr 349,"Search for:\n"<>
$addstr 349," ^_sr_s_str%1..40sn!?7,@\\\\%d\\\\!\n"<>
$addstr 349,"Replace with (blank for Search only):\n"<>
$addstr 349," ^_sr_r_str%0..40sn!?7,@\\\\%d\\\\!\n"<>
$addstr 349,"Options: ^_sr_o_str%0..20snx!348!\n"<>
$addstr 349,"--\n"<>
$addstr 349,"|Keep above settings: ^_sr_k_keep%0..1B[Yes]
[No]\n"<>
$addstr 349,"--\n"<>
$addstr 349,"|%2..1e [OK] [Cancel]"<>
$defstr 348,"Search/Replace Options:\n"<>
$addstr 348," t -- start from Top|@t\n"<>
. . . .
$addstr 348," num repeat num times\n"<>
#if REGEXPS
$addstr 348,"Standard search:\n"<>
#endif
$addstr 348," ? -- wildcard ? on|@?\n"<>
$addstr 348," [ -- search/insert|@[\n"<>
$addstr 348," ] -- search/append|@]\n"<>
#if REGEXPS
$addstr 348,"Regular expressions:\n"<>
$addstr 348," r -- normal|@r\n"<>
$addstr 348," x -- eXtended . matching|@x\n"<>
#endif
$wdb 349<>
$^wdb----<>
$?0^wdb trun 0<>
$^blank=<>
$?=^_sr_r_str,^blank /^_sr_s_str/^_sr_o_str^<>
$?+^_sr_r_str,^blank /^_sr_s_str/^_sr_r_str/^_sr_o_str^<>
 
Example 324. Invoke the Unequal Columns dialog box for a frame
With a frame selected, the macro shown below will invoke the Unequal Columns dialog box. Without the final wdb, and with more script variable entries, this would give a script access to the column settings for a frame.
wdb "_z_",3:tfcol:wdb
 
Example 325. Extract information about a graphic using tgm and wdb
One of the most useful features of the tgm macro is that it can be combined with wdb to extract information about a selected graphic shape. The macro shown below gets the size of the selected shape:
wdb "Height" "Width"
tgm:tgssize
Syntax
wdb string:n? flags:s? script variable:s? exit code:n?
wdb
[no parameter]
Switch off 'invisible' dialog box trapping: this is useful for trapping error conditions. For example, the macro shown below can be used to delete a tag without generating an error message if the tag does not exist.
wdb "_z_":ttagdel "anytag":wdb
string
The number of a string defining a dialog box: the text for the dialog box is taken from the given string number defined in the stuk.3ad system file, in a user strings file, or by a script.
See example (2) for an example of a simple use of the ^wdb variable in a script.
flags
Options for the dialog box:
1
Center the dialog box on the mouse
2
Present in help dialog box format
4
Show no title
8
Show no background (yellow bar)
16
Pass X & Y center position in str (positioned in top left if the value of flags is 8)
32
Pass parameters in an array
64
Called from wdb (so no args on stack)
script variable
One or more variable names, separated by a comma or space character. These variables will be filled by the subsequent call to a dialog box using macro and are filled in in the order in which the dialog box fields are defined. If you do not want to collect information from a specific field, this can be skipped over by using a dummy script variable, e.g. "".
Scripts using the wdb macro in this way are sensitive to the order in which edit boxes appear in an PTC ALD dialog box. PTC reserves the right to alter this order during the development of PTC ALD .
exit code
Returns an exit code to an 'invisible' dialog box. This is useful when a script invokes an are you sure... type of dialog box, that requires an OK response. It can also be used to access some otherwise elusive dialog boxes.
See example (3) for a demonstration of how to invoke the Unequal Columns dialog box using wdb with an exit code.
Additional Information
Macros and scripts can communicate with PTC ALD in many ways, allowing you to extract information about the user's setup or the state of the current document. The simplest way of communicating with PTC ALD is to make an 'invisible' call to one of PTC ALD existing dialog boxes using the wdb macro. Any of the information that you would usually see in a dialog box can be 'pushed' into a variable of your choice.
When used with a script variable, wdb affects the next dialog box that appears. The macro is used to invoke the dialog box whose values are to be passed to one or more script variable items. The dialog box will not be drawn on screen, but its contents will be passed in order to the script variables.
Related Links