Page 1 of 1

Chemstation Report Viewer issue

Posted: Fri Jan 11, 2013 8:08 pm
by MacroMan
LC Chemstation B.04.03. I have run into a problem with showing a macro-generated report (ie. not using the Report Builder). I can print directly to the printer with no issues. However, the help file has an example that uses the "ShowReport" command that is supposed to take a print job and display it. Sort of like Print Preview. When I do this, it basically compresses everything on the page into a straight line across the page instead of showing rows of text. Here is an example:

Name TestReport
LOCAL MyReport$,pWidth,Header$
Header$="Test Report"
OpenDevice "PRINTER" as #7
BeginJob ! will give automatic paging e.g. Page 1 of 2 etc.
pWidth = xMax() ! gets characters per line
SetHeader Header$, pWidth / 2 - Len(Header$) / 2
SetMargin 2, 2, 2
For i=1 to 10
Print #7,"Line "+val$(i)
Next i
EndJob MyReport$ ! redirects report to viewer
SetWinTitle 69, MyReport$
ShowReport 69,MyReport$, "PrintJob", "DelJob" ! displays report viewer
SetActiveWindow 69
Close #7
EndMacro

Any help would be appreciated. I can't find anything in the help files or online that addresses this.
Thanks!

Re: Chemstation Report Viewer issue

Posted: Fri Jan 11, 2013 9:38 pm
by GasMan
Interesting one. I put your macro into the GC ChemStation and it worked OK. The GC ChemStation mentions using the Print Using command. It states if you do not use the "/" character 'the next print command will print on the same line'. Try Print #7 using "/","Line "+val$(i)

Gasman

Re: Chemstation Report Viewer issue

Posted: Wed Feb 13, 2013 4:54 pm
by MacroMan
GasMan,
Thanks for the reply. I tried what you suggested, but it didn't work. I'm not sure why it worked on your GC version. I tried going through Agilent and they sent it to an outside resource that helped me. He was stumped as well, but we finally figured it out. Basically, you have to set the page height and width in the BeginJob command. Then, as the macro prints, calculate how many rows are left until you reach the bottom and send Print #7, " " for each blank row. I re-attached my test report macro for the next guy that tries this. It is working for multiple pages as well.

Name CheckPageRow
If CurrentRow >= pHeight-3-BottomMargin Then
FinishPrinting
FormFeed
CurrentRow=TopMargin+1
Else
CurrentRow=CurrentRow+1
EndIf
EndMacro

Name FinishPrinting
While CurrentRow < pHeight-TopMargin-BottomMargin Do
Print #7," "
CurrentRow=CurrentRow+1
EndWhile
EndMacro

Name TestReport
LOCAL MyReport$,pWidth,pHeight,Header$
Header$="Test Report"

pWidth = XMax() ! gets characters per line
pHeight = YMax()-1!Remove 1 for the automatic "Page # of #" line
Leftmargin=2
TopMargin=2
BottomMargin=2
CurrentRow=TopMargin+1

OpenDevice "PRINTER" As #7
BeginJob,,pWidth,pHeight
SetHeader Header$, pWidth / 2 - Len(Header$) / 2
CheckPageRow
SetMargin LeftMargin, TopMargin, BottomMargin
For i=1 to 100
Print Using #7,"% /", "Line "+Val$(i)
CheckPageRow
Next i
FinishPrinting
EndJob MyReport$ ! redirects report to viewer
SetWinTitle 69, MyReport$
ShowReport 69,MyReport$, "PrintJob", "DelJob" ! displays report viewer
SetActiveWindow 69
Close #7
! Reset printing parameters
SetHeader ""; SetFooter ""
SetMargin 0, 0, 0
EndMacro

Re: Chemstation Report Viewer issue

Posted: Wed Feb 13, 2013 7:43 pm
by GasMan
Macroman,

Thank you for the update. I have seen some problems in my macro generated reports, that if it became a mulitpage report, the second page would be distorted. This only happens if I print to the screen, it is OK if I print direct to the printer. I will try some of your ideas, it might solve my problem

Gasman