A template for the ZocDialog command is a text file which lists and defines the elements that appear within dialog window.
The generalized syntax of a dialog template entry is
<type> <itemid> = "<text>", <val1>, <val2>[, <val3>[, <>val4>]]
e.g.
DIALOG IDDLG0 = "Enter Username", 260,260
The type of the entry is defined by the first word according to the list below (uppercase required). The itemid is a user defined string that can be used to retrieve the item's value after the user closes the dialog (e.g. to check the user's input in a text field). The text depends on the type of item and it is usually either its title or content. Depending on the type of item, val1/val2 are either its x/y location within the window or its size. The values val3/val4 define size (width/height) for those items which have val1/val2 giving a location. Width and height values can sometimes be omitted and to create the item with standard width and height.
The interpreter for these commands is rather basic and unforgiving, so please do not make assumptions about other ways to write the templates beyond the syntax and samples given here and in general do not take syntactical liberties. Strictly one dialog element per line. Lines which start either with // or -- or # are treated as a comment. Empty lines are allowed within the file.
List of possible dialog-template entries:
DIALOG | |
DIALOG <itemid> = "<title>", <width>, <height> | |
STATICTEXT | |
STATICTEXT <itemid> = "<text>", <x-pos>, <y-pos>[, <width>[, <height>]] | |
EDITTEXT | |
EDITTEXT <itemid> = "<contents>", <x-pos>, <y-pos>[, <width>[, <height>]] | |
EDITPASSWORD | |
Same as EDITTEXT, but with hidden input.
| |
CHECKBOX | |
CHECKBOX <itemid> = "<title>", <x-pos>, <y-pos>[, <width>[, <height>]] | |
RADIOBUTTON | |
RADIOBUTTON <itemid> = "<title>", <x-pos>, <y-pos>[, <width>[, <height>]] | |
GROUPBOX | |
GROUPBOX <itemid> = "<title>", <x-pos>, <y-pos>, <width>, <height> | |
DROPDOWNLIST | |
DROPDOWNLIST <itemid> = "<content>", <x-pos>, <y-pos>, <width>, <height> | |
LISTBOX | |
LISTBOX <itemid> = "<content>", <x-pos>, <y-pos>, <width>, <height> | |
PUSHBUTTON | |
PUSHBUTTON <itemid> = "<text>", <x-pos>, <y-pos>[, <width>[, <height>]] | |
DEFPUSHBUTTON | |
Same as PUSHBUTTON but will create a button that is highlighted as the default button (DEFPUSHBUTTON is usually the OK the okay- or finish-button). |
Example: test.dlg
DIALOG MSG1 = "Simple Sample Dialog", 260,140
STATICTEXT ST = "Congratulations! This is your first dialog.", 12,12, 100,60
DEFPUSHBUTTON P1 = "OK", 120,70
// This is another dialog template within the same template file
DIALOG MAIN = "Sample Dialog", 260,310
STATICTEXT ST1 = "Your name", 12,12, 100
EDITTEXT ED1 = "Harry", 112,10
CHECKBOX CB1 = "I am a programmer", 14,50, 150
GROUPBOX G1 = "Your favorite color?", 12, 90, 200,90
DROPDOWNLIST DD1= "Red|[*]Green|Blue", 20,115, 170,100
RADIOBUTTON RB1 = "VT220", 14,190, 80
RADIOBUTTON RB2 = "[*]Xterm", 100,190, 80
DEFPUSHBUTTON P1 = "OK", 12, 230, 80
PUSHBUTTON P2 = "Cancel", 112, 230, 80
Example: Script that uses the above template
CALL ZocDialog "SHOW", "MSG1@test.dlg"
-- show complex dialog and check input
dlgrc= ZocDialog("SHOW", "MAIN@test.dlg")
SAY ">"dlgrc
IF dlgrc=="##OK##" THEN DO
okpressed= ZocDialog("GET", "P1")
IF okpressed==1 THEN DO
SAY "EDITTEXT value: "||ZocDialog("GET", "ED1")
SAY "CHECKBOX value: "||ZocDialog("GET", "CB1")
SAY "DROPDOWNLIST value: "||ZocDialog("GET", "DD1")
END
END
← Back to APPENDIX