Advertisement

set subdir name as 1203311 with Chemstation

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

11 posts Page 1 of 1
Dear all,

I'm trying to program a macro for Chemstation to automatically set the name of the sequence directories as: date01 (e.g. 12033101 for 31st March 2012), date2, etc.

I have written this macro based on the macro from Cyril Messager (C) (http://cyril.messager.free.fr/index.php ... macro.html). I have problems because I cannot obtain the names as I would really like, I can only obtain names as: 2033101 (maximum 7 characters).

Does anyone know why it is not possible to get directories as mentioned before (e.g. 1203311, etc.), with 8 characters (the limiting length for names in Chemstation...)?

Here is the macro:

Name MYSTSBDR

!******************************************************************************
! It updates automatically the data subdirectory.
! When the sequence starts a blank subdir field will
! trigger a start at date01; e.g. "2033101"
! (20331 refer to 31st March 2012)
! If date01 exists, it sets the subdir to date02, etc.
!
! Based on the macro from Cyril Messager (C), cyril.messager@wanadoo.fr
!******************************************************************************

Local Counter, CurDate$

CurDate$ = Date$()

!It isn't posible to create more than 09 directories if date is written as below
!although the total number of characters would be 8 for 99 sequences (?).

!CurDate$ = CurDate$[7:8] + CurDate$[1:2] + CurDate$[4:5]


CurDate$ = CurDate$[8:8] + CurDate$[1:2] + CurDate$[4:5]

counter = 1

WHILE(FileStat(Mode,_DataPath$ + CurDate$ + "0" + Val$(counter)) = 2) DO

counter = counter + 1

If counter = 10 then

WHILE(FileStat(Mode,_DataPath$ + CurDate$ + Val$(counter)) = 2) DO

counter = counter + 1

ENDWHILE

EndIf

ENDWHILE


If counter <10

MkDir _DataPath$ + CurDate$ + "0" + Val$(counter)
_DATASEQSUBDIR$ = CurDate$ + "0" + Val$(counter)

Else

MkDir _DataPath$ + CurDate$ + Val$(counter)
_DATASEQSUBDIR$ = CurDate$ + Val$(counter)

EndIf


SaveSeqParams


EndMacro


SetHook "PreSeq", "MYSTSBDIR"
Hi,
I can't solve your issue, but can offer an alternative.
along the lines of multiple sub-directories.
The advantage of multiple sub-directories, is that after a while a user doesn't
need to scroll through a large number of directories to find
the directory of interest.

I suggest that instead of a directory for a file being \yymmddxx =>
\12033101\xxx.d
a possible idea is that you have \yyyy\mm\ddxx =>
\2012\03\3101\xxx.d
or something similar, because if you ran eg 35 samples per day, that would create 4 folders.
if run for 7 days, that would be a total of 28 folder, so over a year it could be 1,456 folders
per year, etc...
Which a user will be annoyed to sort through each time.


Alex
Dear Alex,

your alternative was our first idea but I'm not able to set the _DATASEQSUBDIR$ as:

_DATASEQSUBDIR$ = CurYY$ + "\" + CurMM$ + "\" + CurDY$ + "_" + "0" + Val$(counter)

where:

CurDate$ = Date$()
CurYY$ = CurDate$[7:8]
CurMM$ = CurDate$[1:2]
CurDY$ = CurDate$[4:5]

So, do you know how we could solve this issue?
For example, should we save sequences in an "ACTUAL" folder and after the sequence is finished, copy them in a "YEAR\MONTH\" folder and delete them afterwards?

I don't know if this reasoning is too complicated and there is another easier option.

Thank you for your help,
Hi,
I am not that familar with the GC/LC macro language. so ALL of the following are WILD GUESSES,

So, I am having a wild guess that _DATASEQSUBDIR$ was not designed to have multiple sub-directories.

If that is the case, then you may need to change your angle of attack, to that of modifying both the
_DATASEQSUBDIR$ and the _DATAPATH$
( n.b. a quick google search suggests you may need to edit _ConfigDataPath$ http://www.chem.agilent.com/Library/use ... 03_ENG.pdf)


so that

Code: Select all

    _DATASEQSUBDIR$ =  CurDY$ + "_" + "0" + Val$(counter)

    _DataPath$ = _DataPath$ + CurYY$ + "\" + CurMM$ + "\"
so that
_DataPath$ goes from C:\Chem32\1\data\ to C:\Chem32\1\data\YY\MM\
and when added all together with the new _DATASEQSUBDIR$ gives
C:\Chem32\1\data\YY\MM\DD_01

WARNING: MAKE SURE _DataPath$ is refreshed before a sequence is run ( I don't know if it is) otherwise on a second sequence
you may get C:\Chem32\1\data\YY\MM\YY\MM\
and a third C:\Chem32\1\data\YY\MM\YY\MM\YY\MM\
etc... as _DataPath$ = _DataPath$ + CurYY$ + "\" + CurMM$ + "\"

double check that the "\" aren't doubling up or missing.

Whilst you could get people to manually copy, some will forget, and others may paste into the wrong directory, the datafile names MUST be unique, as there is a Risk that someone is going to make a mistake, and copy over the top of other files :(, and the finger is going to be pointing at you unfortunately.
or write a macro that post-runs after the data has been acquired and copies the datafile to the new directory structure. p.s. don't let the macro delete the old data, someone has to verified it copied across properly to the new directory first.

I also suggest you use the whole year , as people may confuse the year 12 for the month 12, it looks more professional IMHO.

Code: Select all

CurYY$ = "20" + CurDate$[7:8]
plus I suggest the following 12 If..THEN... statements, so that people can read which month, instead of mentally calculating
which month 05 refers too, the numbers at the front are so that the months are in chronological order, as
windows would otherwise sort them alphabetically and they would be out of order, e.g. as February would appear before January.

Code: Select all

If CurMM$ = "01" then CurMM$ = "01_Jan"
If CurMM$ = "02" then CurMM$ = "02_Feb"
If CurMM$ = "03" then CurMM$ = "03_Mar"
If CurMM$ = "04" then CurMM$ = "04_Apr"
If CurMM$ = "05" then CurMM$ = "05_May"
If CurMM$ = "06" then CurMM$ = "06_Jun"
If CurMM$ = "07" then CurMM$ = "07_Jul"
If CurMM$ = "08" then CurMM$ = "08_Aug"
If CurMM$ = "09" then CurMM$ = "09_Sep"
If CurMM$ = "10" then CurMM$ = "10_Oct"
If CurMM$ = "11" then CurMM$ = "11_Nov"
If CurMM$ = "12" then CurMM$ = "12_Dec"
giving

C:\Chem32\1\data\2012\04_Apr\11_01\xxxxxx.D


Hope the above helps, or gives a clue.
Hi,

Thank you for your suggestions about deleting and copying, and about directories format. I will take them into account, for sure.

I have been trying to change _DATAPATH$ but, since it is a system variable, it is set at the beginning according to the file win.ini, so it's not possible to change this path in Chemstation (at least in the version I'm using (A.10) and, at least, that's what I have understood).

:-(
!It isn't posible to create more than 09 directories if date is written as below
!although the total number of characters would be 8 for 99 sequences (?).

!CurDate$ = CurDate$[7:8] + CurDate$[1:2] + CurDate$[4:5]

CurDate$ = CurDate$[8:8] + CurDate$[1:2] + CurDate$[4:5]
I'm not familiar with the macro language nor with Chemstation at all, but if I interpret the string correctly he uses only the 8th character of the date (guess the "2" from 2012" in the real macro, whereas he states the 7th & 8th caracter ("12") only in the comment ("!")

Do you know why it is so?
What happens if you change [8:8] to [7:8] just like in the comment?
!It isn't posible to create more than 09 directories if date is written as below
!although the total number of characters would be 8 for 99 sequences (?).


!CurDate$ = CurDate$[7:8] + CurDate$[1:2] + CurDate$[4:5]

CurDate$ = CurDate$[8:8] + CurDate$[1:2] + CurDate$[4:5]
counter = 1
WHILE(FileStat(Mode,_DataPath$ + CurDate$ + "0" + Val$(counter)) = 2) DO
counter = counter + 1
If counter = 10 then
WHILE(FileStat(Mode,_DataPath$ + CurDate$ + Val$(counter)) = 2) DO
counter = counter + 1
ENDWHILE
EndIf
ENDWHILE

If counter <10
MkDir _DataPath$ + CurDate$ + "0" + Val$(counter)
_DATASEQSUBDIR$ = CurDate$ + "0" + Val$(counter)
Else
MkDir _DataPath$ + CurDate$ + Val$(counter)
_DATASEQSUBDIR$ = CurDate$ + Val$(counter)

EndIf
Considering his comment about only 9 directories possible with the [7:8] string, I guess there is some additional error within the macro.

The script adds a "0" for all counter <>10, so even for "11" it will create the "0" in the dir name and this will lead to a 9 character name, which isn't allowed.

Therefore I guess the line
If counter = 10 then
should be corrected to the expression >= 10 (or equivalent expression in the macro language)
not sure, if the "if sequence" is executed at all (?)

maybe it would be best to check for counter <10 first, before entering the count up loop.

Maybe something like this (syntax maybe not correct, but hopefully one understands what I mean)

Code: Select all

counter = 1
WHILE(counter <10) DO
  If FileStat(Mode,_DataPath$ + CurDate$ + "0" + Val$(counter)) = 2 then
    counter = counter +1
  EndIf
Endwhile
WHILE(counter >=10) DO
  If FileStat(Mode,_DataPath$ + CurDate$ + Val$(counter)) = 2 then
    counter = counter +1
  EndIf
Endwhile
Dear Hollow,

thanks a lot for your reply, I have checked your proposal and, although it didn't work as it was, I have done a small change and now I get directories as I wanted 12042401,..., 12042412, ....

Here is the code:

Code: Select all


Name MYSTSBDR

        CurDate$ = Date$()
	CurYY$ = CurDate$[7:8]
	CurMM$ = CurDate$[1:2]
	CurDD$ = CurDate$[4:5]

	CurDate$ = CurYY$ + CurMM$ + CurDD$

	counter = 1

	WHILE ((counter <10) AND (FileStat(Mode,_DataPath$ + CurDate$ + "0" + Val$(counter)) = 2)) DO

  		counter = counter +1		

	Endwhile


	WHILE ((counter >=10) AND (FileStat(Mode,_DataPath$ + CurDate$ + Val$(counter)) = 2)) DO

  		 counter = counter +1
		
	Endwhile


	If counter <10

		SetTabHdrText _Sequence[1],"SeqParm","DataSeqSubDir", CurDate$ + "0" + Val$(counter)
		MkDir _DataPath$ + CurDate$ + "0" + Val$(counter)
		_DATASEQSUBDIR$ = CurDate$ + "0" + Val$(counter)

	Else

		SetTabHdrText _Sequence[1],"SeqParm","DataSeqSubDir",CurDate$ + Val$(counter)
		MkDir _DataPath$ + CurDate$ + Val$(counter)
		_DATASEQSUBDIR$ = CurDate$ + Val$(counter)

	EndIf



EndMacro

SetHook "PreSeq","MYSTSBDR"

However, I have still a problem with the .log file, because it is saved for the first time on the default path, and then on the previous directory. So, for example, if I run a sequence I get in C:\HPCHEM\1\DATA the following:

.log file
12042401 > .D files & .B file

Then, if I run another sequence I get:
.log file
12042401 > .D files, .B file & .log file (from sequence 12042402)
12042402 > .D files & .B file

Could anyone give me some insight on what I should change to save .log files correctly in their directories?

Thank you very much.
you're welcome :D
However, I have still a problem with the .log file, because it is saved for the first time on the default path, and then on the previous directory. So, for example, if I run a sequence I get in C:\HPCHEM\1\DATA the following:

.log file
12042401 > .D files & .B file

Then, if I run another sequence I get:
.log file
12042401 > .D files, .B file & .log file (from sequence 12042402)
12042402 > .D files & .B file

Could anyone give me some insight on what I should change to save .log files correctly in their directories?
just hints:
a) was the "SaveSeqParams" string intentionally omitted ?

b) seems for me that the log file is created before the macro is executed and therefore saved in the active directory at that time (which seems to be the one of the previous sequence)
Any possibility to execute the macro before the sequence starts? (I'm not familiar with Chemstation, so this starts exceeding my capabilities...)
bb) what's in this log file? If there are also informations on the execution of the macro then it seems to be "tricky", because the correct directory doesn't exist at the time the log file is created.
maybe you can define a dedicated subdirectory, where only but all .log files are stored? e.g. C:\HPCHEM\1\DATA\LOGS
Thank you Hollow,

I don't know how I should set the directory before the macro starts... :-(

Any suggestion from anyone familiar with Chemstation?

Thanks a lot.
11 posts Page 1 of 1

Who is online

In total there are 356 users online :: 0 registered, 0 hidden and 356 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 356 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