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



Control by External Programs

DataLab can be controlled by external programs by sending a WM_CopyData message to DataLab which contains either a filename of a data file (.IDT- and .ASC files are supported) or the name of a DataLab script (file extension '.ISC'). If the message does not contain a valid filename DataLab either generates an appropriate error dialog or ignores the message (the actual behavior depends on the state of the switch "Display external control error messages").

The filename may either be passed as a fully specified path (disk character, path, and filename) or with no path at all (filename only). If DataLab receives a filename without a path it is assumed that the file to be loaded is located in the current working directory.

If the file extension of the passed filename is '.IDT' or '.ASC' the corresponding data file is loaded. If the file is a script (extension '.ISC') it will be loaded and executed.

In order to control DataLab by an external program, this program first has to create a suitable DataLab script and then pass the filename of the script to DataLab.

When sending the message to DataLab, one of the following error codes are returned:

Error Code Explanation
99 the file specified by the message does not exist
4 unknown command
3 missing argument
2 mismatch in square brackets
1 missing index
0 everything OK, data loaded or script executed successfully
-1 missing assignment in MATH formula
-2 invalid identifier for target variable
-3 left side of equation is wrong
-4 parantheses on the right side of the equation do not match
-5 math error (e.g division by zero)
-6 variable assignment is incomplete
-7 target variable is of categorial type

Example: The following Delphi routine shows an example how to control DataLab by an external program:
(**************************************************************************)
function TForm1.SendMsgToDataLab (DLMsg: string): integer;
(**************************************************************************)

var
  copyDataStruct : TCopyDataStruct;
  receiverHandle : THandle;

begin
copyDataStruct.dwData := 0;
copyDataStruct.cbData := 1 + Length(DLMsg);
copyDataStruct.lpData := PChar(DLMsg);
receiverHandle := FindWindow(PChar('TFrmDataLab'), nil);
if receiverHandle = 0
  then result := -9999
  else result := SendMessage (receiverHandle, WM_COPYDATA,
                              Integer(Handle), Integer(@copyDataStruct)) ;
end;


Last Update: 2012-Aug-05