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


SelectVariables

Declaration: SelectVariables (DataTable: TDataTable; AllowMultiSelect: boolean; PreSelVars: TIntArray; Caption: string; var SelVars: TIntArray): integer;
The function SelectVariables opens the variable selection dialog and returns the selected variables when the user clicks the OK button. The parameter DataTable specifies the data table for which a variable is to be selected. In order to use the main DataLab data container, use the global variable DStore. The parameter AllowMultiSelect controls whether several variables can be selected (TRUE) or only a single one (FALSE). You can pre-select variables by filling the dynamic array PreSelVars by the corresponing variable indices. The parameter Caption is a text which is shown as the caption of the dialog. The indices of the selected variables are returned in the parameter SelVars. If AllowMultiSelect is FALSE SelVars contains only a single index.

The function returns the following error codes:

 0 ... no error, SelVars contains the selected variables
-1 ... the user cancelled the dialog
-2 ... PreSelVars contains invalid variable indices

Example: The following code snippet shows how to use the variable selection dialog. It opens the dialog, showing the variables of the main data container, with the variables 1, 3 and 10 being pre-selected:

var
  i              : integer;
  nvar           : integer;
  vix            : integer;
  SelVars        : TIntArray;

begin
if SelectVariables (DStore, true, [1,3,10], 'Select a variable', SelVars) = 0 then
  begin
  nvar := length(SelVars);
  for i:=1 to nvar do
    begin
    vix := SelVars[i-1];
        // do something with the variable vix
    end;
  end;
end;