Page 1 of 1

A single page with TIC, MS spectrum & lib search spectru

Posted: Wed Jul 08, 2009 9:51 am
by chhubert
Does anyone know how to print a TIC, a mass spectrum, and a library search spectrum on a single page using Agilent MS Chemstation by some macros commands? Meanwhile, I have to print a summary report (two pages) and a mass spectrum + library search spectrum (another page). So a total of 3 pages.

Posted: Wed Jul 08, 2009 6:43 pm
by Consumer Products Guy
Yes, I actually made a macro which does this a few years ago, back when I was young enough to figure out some stuff about macros.

The bad news is I did this for the first Windows-based Chemstaion, but I currently use it on a 6890/5972 Win95/G1701AA system. I haven't tried on newer software, but maybe you could modify if needed for that.

The file on G1701AA is in MSEXE directory, and would replace the current PBMRSLT.MAC, so make a back-up copy of that original PBMRSLT.MAC first before trying this file. Select the following, copy and save to a file called PBMRSLT.MAC and then copy to the MSEXE directory. I only made it red to highlight it.


! ------------------------------------------------------------------
! File: pbmrslt.mac
!
! This set of macros expects the Search Results variable to be
! PBMSEARCHVAR.
! ------------------------------------------------------------------

! ------------------------------------------------------------------
! pbmgrslt
! ------------------------------------------------------------------
NAME PbmGrslt
PARAMETER Hit DEFAULT 1
LOCAL Num_Hits, Quality, Entry_Num, Melt_Pt, Hit_Name$, Boil_Pt
LOCAL CAS_Num$, Mol_Wt, Ret_Index, Lib$

DoSub = 0
IF (Check ("VARIABLE", "PBMShowDiff") = 1) THEN
IF (PBMShowDiff <> 0) THEN
DoSub = 1
ENDIF
ENDIF

GETSCALARS RESULTS, PBMSearchVar, , Hit

! Use 2 windows and 2 variables to avoid flashing
IF (PBMWinGlobal = 0) THEN
R10 = PBMSearchVar
NORMALIZE , R10
GETMSREF Entry_Num, Lib$, R11, FULLMS
NORMALIZE , R11
IF (DoSub = 1) THEN
R12 = R10 - R11
ENDIF
JOIN R10, R11
IF (Dosub = 1) THEN
JOIN R10, R12
ENDIF
DRAW 24, R10
PBMWinGlobal = 1
CLEAR 26
ELSE
R13 = PBMSearchVar
NORMALIZE , R13
GETMSREF Entry_Num, Lib$, R11, FULLMS
NORMALIZE , R11
IF (Dosub = 1) THEN
R14 = R13 - R11
ENDIF
JOIN R13, R11
IF (DoSub = 1) THEN
JOIN R13, R14
ENDIF
DRAW 26, R13
PBMWinGlobal = 0
CLEAR 24
ENDIF
IF (CSExists (CAS_Num$, StrucDB$) > 0) THEN
S = CSCreate (CAS_Num$, StrucDB$)
SW = CreateWindow (S, 100, 0.77:1, 0:PBMWINHEIGHT)
SetWindowText SW, Hit_Name$
SetWindowLoc "PBM Search", 0, PBMWINHEIGHT
ELSE
SW = 0 ! Remove previous window
REMOVE S
PRINT "No structure found for CAS # " + CAS_Num$
ENDIF
RETURN ! PbmGrslt

NAME PbmPrint
PARAMETER HitNum DEFAULT 1
LOCAL Num_Hits, Quality, Entry_Num, Melt_Pt, Hit_Name$, Boil_Pt
LOCAL CAS_Num$, Mol_Wt, Ret_Index, Lib$
LOCAL Row, Col, StartStr, EndStr, MaxStr, Num, WinSize, Length
LOCAL ObjForStructure

GETSCALARS RESULTS, PBMSearchVar, , HitNum
STARTPRINT
PAGESIZE col,row
STRPRINT "Library Searched : " + Lib$, 5, 28
STRPRINT "Quality : " + Val$ (Quality), 5, 29

! Figure out how many lines of text are needed to display the id.
! The id label takes up 19 spaces and we want to leave some space
! for the right side margin.
MaxStr = Col - 19 - 6
Length = LEN (Hit_Name$)
Num = 1
IF (Length <= MaxStr) THEN
STRPRINT "ID : " + Hit_Name$, 5, 30
ELSE
STRPRINT "ID : " + Hit_Name$ [1:MaxStr], 5, 30
EndStr = MaxStr
WHILE (EndStr < Length)
StartStr = EndStr + 1
EndStr = StartStr + MaxStr - 1
IF (EndStr > Length) THEN
EndStr = Length
ENDIF
STRPRINT " " + Hit_Name$ [StartStr:EndStr], 5, (3 + Num)
Num = Num + 1
ENDWHILE
ENDIF

! Compute the window size. Make sure to leave one line of
! space after the id and some space for the bottom margin.
! Divide the space in thirds so that structure can print if it is available
WinSize = (Row - (4 + Num) - 1 ) / 3.8
IF (PBMWinGlobal = 1) THEN
WinNum = 24
ELSE
WinNum = 26
ENDIF
WINPRINT WinNum, 4, (30 + num), (Col - 6), 2 * WinSize
IF (CHECK("variable","S") = 1) THEN
ObjForStructure = PBMSearchVar
GETSCALARS ,PBMSearchVar
CSAttach S, ObjForStructure, 2*xhigh*20:(2*xhigh + 1000) * 20, ylow:yhigh
SETWINATTRIBUTE 30, cursorshape, 13
SETWINATTRIBUTE 30, showtitles, 0
DRAW 30, ObjForStructure, 2*xhigh:2*xhigh+1000,ylow:yhigh

CLEAR 30
SETWINATTRIBUTE 30, cursorshape, 1
SETWINATTRIBUTE 30, showtitles, 1
ENDIF


LOCAL numwindows,col,row,half,startcol,rownum,tempout$,hdr$,i
numwindows = 0

IF CHECK("VARIABLE","_OPERATOR$") = 0
PRINT "No current data file has been established"
RETURN TSCleanup
ENDIF
! let these guys handle their own errors.
PAGESIZE col,row

MACRO "filehdr.mac"
HdrFormat hdr$
REMOVE HdrDisp,HdrFormat
ON ERROR numwindows = 1
startcol = 4
rownum = 0
STRPRINT hdr$[1],startcol,rownum+1
STRPRINT hdr$[2],startcol,rownum+2
STRPRINT hdr$[3],startcol,rownum+3
tempout$ = "Instrument : " + _instname$
STRPRINT tempout$,startcol,rownum+4
STRPRINT hdr$[4],startcol,rownum+5
STRPRINT hdr$[5],startcol,rownum+6
STRPRINT hdr$[6],startcol,rownum+7
PRINT
rownum = rownum+9
row = row - 3
col = col - startcol - 2
half = floor((row-rownum)/2)

ON ERROR numwindows = numwindows + 2
WINPRINT 2,startcol,rownum,col,18
PRINT
IF numwindows >= 6
PRINT "Nothing drawn in windows 1 and 2"
RETURN TSCleanup
ENDIF
ENDPRINT
IF numwindows >= 4
PRINT "Printed window 2"
RETURN TSCleanup
ENDIF
IF numwindows >= 2
PRINT "Printed window 1"
RETURN TSCleanup
ENDIF
IF numwindows = 1
PRINT "No file loaded. Printed windows 1 and 2"
RETURN TSCleanup
ENDIF




RETURN ! PbmPrint

NAME PbmRslts
PARAMETER ForceGraph DEFAULT 0
LOCAL Num_Hits, Quality, Entry_Num, Melt_Pt, Hit_Name$, Boil_Pt
LOCAL CAS_Num$, Mol_Wt, Ret_Index, Lib$

IF (ForceGraph <> 0) THEN
SaveButton = 0
ELSE
SaveButton = _BUTTON
ENDIF

! Save graphics format
IF (CHECK ("VARIABLE", "PBMSaveFormat") = 0) THEN
PBMSAVEFORMAT = MENUSTATE (500)
PBMSAVESCALE = MENUSTATE (502)
FORMAT SEPARATED, , , 0
WINDOW 26, 0:1, PBMWinHeight:1
WINDOW 24, 0:1, PBMWinHeight:1
ENDIF

! See which button was pressed
IF (SaveButton = 0) THEN ! do graphics
PbmGrslt Hit
ENDIF
IF (SaveButton = 1) THEN ! do statistics
TABULATE RESULTS, , PBMSEARCHVAR
ENDIF
IF (SaveButton = 2) THEN ! do text results
VIEWPBMTEXT PBMSearchVar, Hit
ENDIF
IF (SaveButton = 3) THEN ! do print
PbmPrint HIT
ENDIF
IF (SaveButton = 4) THEN ! done
! Restore graphics format
IF (PBMSaveFormat = 1) THEN
FORMAT MERGED
ELSE
FORMAT SEPARATED
ENDIF
IF (PBMSaveScale = 1) THEN
FORMAT , , 1, 1
ELSE
FORMAT , , 1, 0
ENDIF
if (check("macro","PRPositionResults") = 1)
PRPositionResults
endif
REMOVE PBMSaveFormat, PBMSaveScale, R10, R11, R12, R13, R14, S, SW
REMOVE PbmRslts, PbmPrint, PbmGrslt, LibSrch
ENDIF
PRINT
RETURN ! PbmRslts

! ------------------------------------------------------------------
! PbmInitRslts
!
! This macro should always be the last one in the file.
! ------------------------------------------------------------------
name PbmInitRslts
PBMWINGLOBAL = 0
LIBRESULTS PBMSEARCHVAR

! Show first hit
HIT = 1
PbmRslts 1
RETURN

Posted: Thu Jul 09, 2009 5:32 am
by chhubert
It works excellently. Thanks a lot.

Hubert

Posted: Thu Jul 09, 2009 5:47 pm
by Consumer Products Guy
It works excellently. Thanks a lot.

Hubert
Great (I know I wouldn't be able to re-create today the macro modification I did "back then"). So what version of the GCMS ChemStation are you using it on?

Posted: Fri Jul 10, 2009 10:29 am
by chhubert
It works excellently. Thanks a lot.

Hubert
Great (I know I wouldn't be able to re-create today the macro modification I did "back then"). So what version of the GCMS ChemStation are you using it on?
I use G1701CA version of MS Chemstation, running in Windows NT platform. Also if I wanna know more about macros programming for MS Chemstation, do you have any suggestion? I do have a booklet from Agilent (or HP) on how to write macros but it seems to be quite elementary.

Hubert