Page 1 of 1

OpenLab macros

Posted: Thu Oct 18, 2012 7:59 pm
by suchsimion
When using the show command to bring up the dialogbox showing all the domains with variables, macros, functions etc., it lists over 3000 macros. I know most macros are stored in the Core directory and that some macros can be nested inside other macro files. Where are the rest of the macros stored that are listed in the show dialog? Thanks

Re: OpenLab macros

Posted: Fri Oct 19, 2012 12:31 pm
by GasMan
The macros themselves are stored in macro files. These have the extension .mac or .mcx. A macro file can contain many macros. Macro files with the .mac extension can be opened and read with NotePad. The macro files with the .mcx extension are in a binary format and cannot be read. If you type the word 'macro' into the command line instead of 'show', you will get a list of macro files that are available. If you then open a file up, you will then see the macros in that file.

When you type in 'show', you are seeing the results of loading macro files into ChemStation. For example: If you had a macro file named 'mymacros.mac' in the core directory and this contained three macros named 'test1', 'test2' and 'test3', you would not see these macros in the list when you type in 'show'. If you type into the command line the command 'macro mymacros.mac', that file would be loaded into ChemStation. Now if you type in 'show', you would see your macros 'test1', 'test2' and 'test3' in the list of macros.

I thik that it will take a bit of detective work for you to find what you want..............

Gasman

Re: OpenLab macros

Posted: Fri Oct 19, 2012 1:24 pm
by suchsimion
Thanks Gasman. I knew about the .mac files but didn't know about the .mcx files -thanks good advice. I'm using macropad to write macros instead of notepad. It works much better than notepad and will allow you to run and test the macro from macropad itself. Will check and see if I can decipher those .mcx files.

Thanks

Re: OpenLab macros

Posted: Tue Oct 23, 2012 3:59 pm
by GasMan
Although it is not possible to read .mcx files, it is possible for you to convert your .mac files to the .mcx format. This prevents other people reading your work or going in your macro and changing things.

Gasman

Re: OpenLab macros

Posted: Sat Mar 29, 2025 4:16 am
by hts123
May I check is there any way to write macros that can automate the following :

1) for each peak, print the overlaid uv spectrum of the match with that of the compound in a library ? Save the overlaid spectrum as a pdf file in a folder of choice .

I remembered seeing .mcx file in the open lab chemstation but I am unsure how to write macros. Can we write macros in a notepad and save as .mcx file and run on the system?

Is it true that currently the open lab chemstation uses DDE (dynamic data exchange) instead of COM Objects and if I need to run the macros, I need to activate through excel VBA?

I look forward to the replies! :D

Thank you very much!

Re: OpenLab macros

Posted: Sun Mar 30, 2025 6:44 am
by antonk
.mac - are text files, .mcx - binary, only HP/Agilent adepts know how to build it.

Your task somewhat resolved in UCL (user contributed library) which is shipped on every Chemstation CD.

Here is example of macro that exports base peak parameters to Excel.
Just create text file mymacro.mac, containing the following:

name exp_dde
local npeaks,cpk,t1,a1,ct$,ca$,tv$,av$
npeaks = TabHdrVal(ChromRes[1], "Peak", "NumberOfRows")
If (npeaks <= 0) then
return
EndIf

chan = DDEInitiate("Excel","Sheet1")

for cpk=1 to npeaks
t1 = TabVal(ChromRes[1], "Peak", cpk, "MeasRetTime")
a1 = TabVal(ChromRes[1], "Peak", cpk, "Area")
ct$ = printf$("R%dC%d",cpk,1);
ca$ = printf$("R%dC%d",cpk,2);
tv$ = printf$("%.3f",t1)
av$ = printf$("%g",a1)
DDEPoke chan,ct$,tv$
DDEPoke chan,ca$,av$
next cpk

DDETerminate chan
endMacro

load the file from the famous commandline and type
exp_dde

Re: OpenLab macros

Posted: Wed Apr 02, 2025 12:32 pm
by hts123
@antonk, thank you for the reply. I read in the chemstation macro programming guide that there is a window 28 which "Print spectra from peak purity and library search plot macros (Report)". Does this window 28 refer to macro or just the window number?

I am relatively new to macros.... do you have a snapshot as to where I could enter my macro in the command line in the OpenLAB CDS
ChemStation Edition Offline Data Analysis? Thank you so much for the help. :D

Re: OpenLab macros

Posted: Wed Apr 09, 2025 5:51 am
by antonk
@antonk, thank you for the reply. I read in the chemstation macro programming guide that there is a window 28 which "Print spectra from peak purity and library search plot macros (Report)". Does this window 28 refer to macro or just the window number?
window number
I am relatively new to macros.... do you have a snapshot as to where I could enter my macro in the command line in the OpenLAB CDS
ChemStation Edition Offline Data Analysis? Thank you so much for the help. :D
As far I remember you have to enable "Extended menus" in Chemstation, only in that case your commandline would be visible