Control by External Programs

can be controlled by external programs by sending a Windows WM_CopyData message to which contains either a filename of a data file (.ILAB file) or the name of an script (file extension '.ISCR'). If the message does not contain a valid filename either generates an appropriate error dialog or ignores the message (the actual behavior depends on the state of the switch "Provide a Status Message on Faulty External Control").

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 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 '.ILAB' the corresponding data file is loaded. Please note that a complete dataset consists of several files (.ilab and .cube as a minimum).

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

Hint: Please note that full external control via ILabPascal scripts is only possible if you are using the Extended Version of .

 

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

Error Code Explanation
0 everything OK, data loaded or script executed successfully
-1 the script or file specified by the script does not exist
-2 script is too old (minimum required version is higher than installed version)
-3 script execution error
-4 script compilation failed
-5 script aborted by user

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

var
  copyDataStruct : TCopyDataStruct;
  receiverHandle : THandle;

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