6.10.7 Building a command line dialog box

When dening a tool, it is possible to show a dialog to the user, asking for additional arguments, using the $PROMPT(filename) command-macro. Free Pascal comes with some dialogs, such as a 'grep' dialog, a 'cvs checkout' dialog and a 'cvs check in' dialog. The les for these dialogs are in the binary directory and have an extension .tdf.

In this section, the le format for the dialog description le is explained. The format of this le resembles a windows .INI le, where each section in the le describes an element (or control) in the dialog. An OK and an Cancel button will be added to the bottom of the dialog, so these should not be specied in the dialog denition.

A special section is the Main section. It describes how the result of the dialog will be passed on the command-line, and the total size of the dialog.

Remark: Keywords that contain a string value, should have the string value enclosed in double quotes as in

Title="Dialog title"

The Main section should contain the following keywords:

Title
The title of the dialog. This will appear in the frame title of the dialog. The string should be enclosed in quotes.
Size
The size of the dialog, this is formatted as (Cols,Rows), so
Size=(59,9)

means the dialog is 59 characters wide, and 9 lines high. This size does not include the border of the dialog.

CommandLine
species how the command-line will be passed to the program, based on the entries made in the dialog. The text typed here will be passed on after replacing some control placeholders with their values.

A control placeholder is the name of some control in the dialog, enclosed in percent (%) characters. The name of the control will be replaced with the text, associated with the control. Consider the following example:

CommandLine="-n %l% %v% %i% %w% %searchstr% %filemask%"

Here the values associated with the controls named l, i, v, w and searchstr and filemask will be inserted in the command-line string.

Default
The name of the control that is the default control, i.e. the control that has the focus when the dialog is opened.

The following is an example of a valid main section:

[Main]  
Title="GNU Grep"  
Size=(56,9)  
CommandLine="-n %l% %v% %i% %w% %searchstr% %filemask%"  
Default="searchstr"

After the Main section, a section must be specied for each control that should appear on the dialog. Each section has the name of the control it describes, as in the following example:

[CaseSensitive]  
Type=CheckBox  
Name="~C~ase sensitive"  
Origin=(2,6)  
Size=(25,1)  
Default=On  
On="-i"

Each control section must have at least the following keywords associated with it:

Type
The type of control. Possible values are:
Label
A plain text label which will be shown on the dialog. A control can be linked to this label, so it will be focused when the user presses the highlighted letter in the label caption (if any).
InputLine
An edit eld where a text can be entered.
CheckBox
A Checkbox which can be in a on or o state.
Origin
Species where the control should be located in the dialog. The origin is specied as (left,Top) and the top-left corned of the dialog has coordinate (1,1) (not counting the frame).
Size
Species the size of the control, which should be specied as (Cols,Rows).

Each control has some specic keywords associated with it; they will be described below.

A label (Type=Label) has the following extra keywords associated with it:

Text
the text displayed in the label. If one of the letters should be highlighted so it can be used as a shortcut, then it should be enclosed in tilde characters (~), e.g. in
Text="~T~ext to find"

The T will be highlighted.

Link
here the name of a control in the dialog may be specied. If specied, pressing the label's highlighted letter in combination with the Alt key will put the focus on the control specied here.

A label does not contribute to the text of the command-line, it is for informational and navigational purposes only. The following is an example of a label description section:

[label2]  
Type=Label  
Origin=(2,3)  
Size=(22,1)  
Text="File ~m~ask"  
Link="filemask"

An edit control (Type=InputLine) allows to enter arbitrary text. The text of the edit control will be pasted in the command-line if it is referenced there. The following keyword can be specied in a inputline control section:

Value
here a standard value (text) for the edit control can be specied. This value will be lled in when the dialog appears.

The following is an example of a input line section:

[filemask]  
Type=InputLine  
Origin=(2,4)  
Size=(22,1)  
Value="*.pas *.pp *.inc"

A combo-box control (Type=CheckBox) presents a checkbox which can be in one of two states, on or off. With each of these states, a value can be associated which will be passed on to the command-line. The following keywords can appear in a checkbox type section:

Name
the text that appears after the checkbox. If there is a highlighted letter in it, this letter can be used to set or unset the checkbox using the Alt-letter combination.
Default
species whether the checkbox is checked or not when the dialog appears (values on or off)
On
the text associated with this checkbox if it is in the checked state.
O
the text associated with this checkbox if it is in the unchecked state.

The following is a example of a valid checkbox description:

[i]  
Type=CheckBox  
Name="~C~ase sensitive"  
Origin=(2,6)  
Size=(25,1)  
Default=On  
On="-i"

If the checkbox is checked, then the value -i will be added on the command-line of the tool. If it is unchecked, no value will be added.