Control by External Programs

Epina ImageLab can be controlled by external programs by sending a Windows WM_CopyData message to Epina ImageLab which contains either a filename of a data file (.ILAB file) or the name of an Epina ImageLab script (file extension '.ISCR'). If the message does not contain a valid filename Epina ImageLab 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 Epina ImageLab 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 Epina ImageLab dataset consists of several files (.ilab and .cube as a minimum).

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

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

 

When sending the message to Epina ImageLab, 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 Epina ImageLab 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 Epina ImageLab 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;