DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


ShowDialog

Declaration: ShowDialog: TVariantArray;
Displays the input dialog which has been created by CreateDialog and optionally adapted by ConfigDlgComponent. The dialog is always a modal window which can be closed either by clicking the OK button or by clicking the cancel button in the upper right corner of the dialog.

The entered parameters are returned as an open variant array. The number of returned variants N is equal to the number of defined components P plus 1. The variant array has a 0-based index. The array element with index 0 returns an error code, all other elements (1..N) return the input values of the components of the dialog. Please note that the numeric input component (gcNumIO) returns two results, namely the numeric value and the state of the freeze button.

The available input components return the following results:

Component Type of Returned Value Explanation
gcCheckBox boolean TRUE if checked, FALSE if not checked
gcColorSel integer Color value of the selected color; the colors are encoded as RGB values with inverted color order (blue-green-red: the red value occupies the least significant byte)
gcDropDown integer The index of the selected option
gcEdit string The text entered in the input field
gcLabel - The label component does not return any value
gcNTabEd TDoubleArray The returned open array contains the values entered in the editable column of the table. Please note that due to compiler restrictions you cannot directly access the returned array, you have to copy it to an auxiliary array in order to access the individual elements of the returned open array.
gcNumIO TVariantArray [double,boolean] The returned array has two elements, element 0 contains the double precision floating point value of the input field, element 1 reflects the state of the freeze button (i.e. this value is TRUE if the freeze button has been checked). Please note that due to compiler restrictions you cannot directly access the returned array, you have to copy it to an auxiliary array in order to access the individual elements of the returned open array (see the code example below).
gcRadioBox integer The index of the selected option (1-based)

The function returns the following error codes:

 0 ... everything is OK
-1 ... the dialog does not exist (CreateDialog was not called)
-2 ... the component does not exist
-3 ... invalid parameter

Sample
program:
The following script displays a dialog with four elements which allow for the input of a name and three body parameters:
program AskBodyData_V1;

var
  DlgResults     : TVariantArray;
  aux            : TVariantArray;

begin
CreateDialog (150,10,'Sample Dialog',
              [gcLabel, gcEdit, gcCheckbox, gcNumio, gcNumio, gcRadioBox, gcColorSel],
              ['', 'Name', 'Left handed', 'Body height [cm]', 'Shoe Size',
               'Eye color|Please select closest color', 'Your favorite color']);
ConfigDlgComponent(1,'left=10;val=Please enter your body data:');
ConfigDlgComponent(4,'box=unchecked;rtxt=auto');
ConfigDlgComponent(6,'hgt=125;opt=brown|blue|gray|green|other;val=2');
DlgResults := ShowDialog;
if DlgResults[0] = 0 then
  begin
  cout ('Name: ',DlgResults[2]);
  cout ('Left handed: ',boolToStr(DlgResults[3],0));
  aux := DlgResults[4];
  cout ('Body height: ', aux[0]);
  cout ('Body height freeze box checked: ', aux[1]);
  aux := DlgResults[5]
  cout ('Shoe size: ',aux[0]);
  cout ('Eye color: ',IntToStr(DlgResults[6]));
  cout ('Favorite Color: ', Hex(DlgResults[7],8));
  end;
end.

This dialog exhibits a few weaknesses: (1) the range of allowed parameters is given by the default values (0..1000) which is not meaningful, (2) no initial values are displayed and (3) the precision of the numeric input values is two decimal places by default (which is nonsense, nobody specifies for example the shoe size with two decimal places). The function ConfigDlgComponent can be used to adjust the input components accordingly.