Page 1 of 1
Agilent macro programing
Posted: Wed Sep 26, 2007 7:26 pm
by sergioanis
I'm writing a macro to automatically process data contained in the AEV files, so according to the manual I should do something like:
open aevfile$ for input as #10
open processed$ for input as #20
execwait "myprogram", #10, #20
close #10
close #20
when I do that, the compiler throws a 'parse' error on the execwait command.
If i do: execwait "test_program"
the test program run properly
So I tried to pass the aevfile$ as a parameter:
execwait "myprogram aevfile$"
but it does not interpret the aevfile$ as a variable. It consider it a string and passed to myprogram.
I'd appreciate any help on this problem.
thanks,
Sergio
Posted: Thu Sep 27, 2007 9:04 am
by GasMan
Sergio,
Do you have the following information about the ExecWait command.
Executes the specified program.
Group
Application Control commands
Syntax
ExecNoWait Program_Specification, [Appearance], [InputFileNum] ,[OutputFileNum] ,[ErrorFileNum]
ExecNoWait( Program_Specification, [Appearance], [InputFileNum] ,[OutputFileNum] ,[ErrorFileNum] )
ExecWait Program_Specification, [Appearance], [InputFileNum] ,[OutputFileNum] ,[ErrorFileNum]
ExecWait( Program_Specification, [Appearance], [InputFileNum] ,[OutputFileNum] ,[ErrorFileNum] )
Parameters Type/Description
Program_Specification String expression identifying a program and its parameters.
Appearance Numerical expression evaluating into an integer
InputFileNum File number. Given file is used as input file of the program being executed.
OutputFileNum File number. Given file is used as output file of the program being executed.
ErrorFileNum File number. Given file is used as error file of the program being executed.
Discussion
ExecNoWait and ExecWait are available as commands and functions. They execute the specified program. When using ExecNoWait, the CP does not wait for the program to finish before executing its next command. ExecWait returns the program's return value, while ExecNoWait returns the task id of the application if it actually starts.
An application name without absolute path is specified from the applications current working directory.
Appearance controls the display behavior on the graphical user interface for the started program. The number has the following meaning:
1 = normal sized window
2 = icon
3 = maximum sized window
If number is omitted it defaults to 2.
By providing file descriptors for the program to read its input from InputFileNum, write its output to OutputFileNum and finally writes its errors to ErrorFileNum, the macro writer has more control over the program being executed by ExecWait/ExecNoWait.
The use of the file descriptor parameters InputFileNum, OutputFileNum and ErrorFileNum is only possible when staring DOS programs. It is not valid when starting MS-WINDOWS applications.
For backwards compatibility for previous versions the function Exec() is available, but usage of ExecNoWait() function is suggested.
ExecNoWait() is typically used before DDEInitiate to start a DDE conversation with an particular instance of an application.
Return Value
Number (if called as a function)
Copyright (c) 1990-2002 Agilent Technologies
It is normally used to call an executable program. Please not that to pass parameters, the program must be a DOS program, not a MS Windows program.
Gasman
Posted: Thu Sep 27, 2007 12:04 pm
by sergioanis
hi Gasman,
you can pass a parameter as shown in the example 1, just after the info you copy here, although they pass a string not a variable (which my need is)
I wrote the programs that execwait call, as I said before they execute properly if I don't pass the file ID.
The problem seems to be the syntax of the call:
execwait "myprogram", #10, #20
the Agilent Macro Compiler doesn't like it, for some reason
Thanks,
Sergio
Posted: Thu Sep 27, 2007 12:40 pm
by GasMan
Sergio,
It is not clear to me what you are trying todo.
Is the program you are trying to execute a macro or a standalone program. Why can you not open the files in your program and then just call the program. As I use the ExecuteWait command, it is to start a program that is OUTSIDE of the Chemstation. When you open a file with a macro, it is for use within the Chemstation macros, not for an external program.
Gasman
Posted: Thu Sep 27, 2007 12:53 pm
by sergioanis
the workflow is:
* chemist put a sample to run using EazyAccess
* sample run: during data processing the AEV report file is created;
* inside the AEVGEN.MAC (as last step, before closing) I put the call to myprogram (which needs the name and path to the AEV file just created)
* myprogram will: process the AEV file, upload some data into the company's data base, write a file into the data file folder
* EazyAccess email to the chemist the html report and the file created by myprogram
nice and simple, if just execwait worked as expected
regards,
Sergio
Posted: Thu Sep 27, 2007 4:12 pm
by GasMan
Sergio,
In what language is the program 'myprogram' written in. Will it support DDE. If so, it may be possible to get the information from the ChemStation into your program.
The only other way that I can see to do this is store the information that you are trying get to your program in an external file. You can then get the program 'myprogram' to read this file.
Gasman
Posted: Thu Sep 27, 2007 6:16 pm
by sergioanis
I'm using Tcl, I don't know if it supports DDE.
You are right: I can write the path to a file and read it from there. I should have thought about it before.
thanks for the idea
Sergio