Advertisement

Export of Chromatograms (Sequence) - ChemStation Macro

Discussions about chromatography data systems, LIMS, controllers, computer issues and related topics.

2 posts Page 1 of 1
I stumbled across this forum during my search for a solution for my Macro-Problem (till now I only know that many people do want to have such a Macro, but I wasn't able to find anything functional).

The task would be to extract the chromatograms of a complete sequence (all available signals as we often monitor at 210, 280, and maybe additional wavelengths) from an HPLC system (ChemStation B.04.03) and write them to .csv files for further processing (with appropriate file and sequence name).

I'm stuck at the moment switching from one sample to the next one and I hope that someone can help me (especially with the LoadSignal command, I can't figure it out just using the manual and maybe this would be the possibility to loop through the samples)

The macro I have so far is:

Name csvfile5 !Command for starting the macro
!This would be the place to insert a loop of some kind to loop through the sequence
!Define Local Variables

Local cols,runtime,signal,i,j

!How many objects are there in the Working Register
for j=1 to RegSize(Chromreg) !Loop through all Objects in the Register Chromreg
cols=DataCols (Chromreg[j])
Open "C:\temp\" + _SeqFile$ +"-" + DADATAFILE$ + "Signal"+Val$(j)+".csv" For Output as #5 !Defining Output File
Print "Saving C:\temp\" + _SeqFile$ +"-" + DADATAFILE$ + " Signal" + Val$(j) + ".csv" !Just writing that it works

For i=1 To cols !Building up the .csv File
runtime=Data (Chromreg[j],0,i)
signal=Data (Chromreg[j],1,i)
print#5,runtime,";",signal
Next i
Close#5 !Close the Output File
next j
!If there is a command for the next sample, this would be the place
Print "Finished"
endmacro

Well, it runs nice if I select my sample and start the macro (it then writes .csv for this one sample). Now I suspect there has to be some Object containing all samples (some kind of sequence object) where i could loop through this sequence object just the same as through the different signals.
Or maybe there is a predefined macro to go to the next sample (as there is a button which does exacly this in the batch processing window).

If any one could help that would be very very great.
(and please no links to any commercially or freely available software to decode .D files, if there is any possibility to solve this through a macro this would be better)

Many thanks in advance
Peter
If anyone is interested, here is my workaround. It's a bit slow and a bit confusing, but I like to share it, maybe someone can also use this (or maybe refine it)

Some notes to the functionality:
There must be a folder c:\temp\, this is the results folder
Select a signal and one run of the sequence you want to have extracted
Signals must be (I don't know why) in the format that you see the different signals of one sample in separate chromatograms
The sample number in the file name does NOT correspond to the number in the sequence or the vial (it was just for my reference)
All samples have to have the same number of signals (so if you have 210nm 280nm and 600nm, there should be 3 signals for every sample in the sequence)
If the sequence aborted and there are folders with .D without signals, delete them before starting the macro


Name getcsv2 !Command for starting the macro
Local cols,runtime,signal,i,j,p,a,n

!Count the files in the directory of the selected Sequence
Filestring$ = FindFile$(_seqpath$+"*.D",,"%")
a=0
n=1
while substring$(Filestring$,n,,"%") <> ""
a = a+1
print substring$(Filestring$,n,,"%")
n = n+1
endwhile

!Determine how much signals are / sample
AnzahlSignals = RegSize(Chromreg)
print AnzahlSignals
sleep 1

!load all signals of the sequence into the Chromreg
For p = 1 to a
ActiveFileName$ = substring$(Filestring$,p,,"%")
ActiveFilePathName$ = _seqpath$+activefilename$
print ActiveFilePathName$
Sleep 0.5
File ActiveFilePathName$
LoadSignal ,,,Chromreg
Next p

Samplecount = 0
k = 0

!How many objects are there in the Chromreg
For j=AnzahlSignals+1 to RegSize(Chromreg) !Loop through all Objects in the Register Chromreg without the first sample (as this is the one that was selected, and it is imported a second time anyways)
cols=DataCols (Chromreg[j])

!count for the sample number (as there are all signals in one Register, there is a need to count the sample)
k = k+1
If k = 1 then
Samplecount = Samplecount+1
endif

Open "C:\temp\" + _SeqFile$ +"-" + substring$(Filestring$,Samplecount,,"%")+"-SampleNr." + Val$(Samplecount)+"-Signal"+Val$(k)+".csv" For Output as #5 !Defining Output File
Print "Saving C:\temp\" + _SeqFile$ +"-" + substring$(Filestring$,Samplecount,,"%") +"Signal"+ Val$(k) + ".csv" !Just writing that it works

For i=1 To cols !Building up the .csv File
runtime=Data (Chromreg[j],0,i)
signal=Data (Chromreg[j],1,i)
print#5,runtime,",",signal
Next i

!setting back the signal counter
if k = AnzahlSignals then
k = 0
endif

Close#5 !Close the Output File

next j

Print "Finished" !defining the finish line
endmacro !End the Macro
2 posts Page 1 of 1

Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 5 minutes)
Most users ever online was 4374 on Fri Oct 03, 2025 12:41 am

Users browsing this forum: No registered users and 13 guests

Latest Blog Posts from Separation Science

Separation Science offers free learning from the experts covering methods, applications, webinars, eSeminars, videos, tutorials for users of liquid chromatography, gas chromatography, mass spectrometry, sample preparation and related analytical techniques.

Subscribe to our eNewsletter with daily, weekly or monthly updates: Food & Beverage, Environmental, (Bio)Pharmaceutical, Bioclinical, Liquid Chromatography, Gas Chromatography and Mass Spectrometry.

Liquid Chromatography

Gas Chromatography

Mass Spectrometry