Technical Issues - Report Generator Tutorial II - AdvancedThe Report Generator becomes truly useful when reports include calculated results as well as graphs. For example 'Coating PASSED Specifications' based on average and maximum reflectance. While setting up reports requires some effort, QA technicians and other end-users need have no idea of the inner workings. Creating Text: Action command FileText is useful for boilerplate text that's used repeatedly. A one line Report Template is all that is needed. In this case the template contains no font information so the default font is utilized. <<FileText c:\Winfilm\Data\LoremIpsum.txt>>
The next step is to customize the text. One possibility is to generate the entire Report Template in BASIC. BASIC's Replace function can then substitute computed text.
Alternatively we can paste text into the Report Template and then use BasText to insert computed values. Since the Report Template is saved with the FILM Archive (Scan Method) this method is more portable as another user would not need a copy of LoremIpsum.txt. On the other hand, when there are several pages of boilerplate (as in 'Terms and Conditions') it makes sense to add these with FileText.
The Report Generator automatically replaces <<BasText n>> with quantity BasText(n) previously defined in BASIC as shown in the brief code sample below. Up to 16 quantities (n = 0...15) are possible.
A relatively new addition (July 2011) to the Report Template is BasExec whereby BASIC code is inserted directly in the Report Template. By first defining BasText(0) we ensure that its value is available when the Report Generator encounters <<BasText 0>>. BasExec automatically adds Sub Main and End Sub; the pipe symbol "|" separates lines of code.
While BasExec is suitable for short code segments, BasRun should be used for longer programs. In that case we could replace the BasExec action command with <<BasRun c:\Winfilm\Basic32\Henry.bas>>
Another comparison of BasExec and BasRun can be found in Including Date/Time in a FilmStar Report. Another BasRun example is given here. Using the Workbook: Consider how we might create a QA report for a BBAR 450-750 nm coating which passes if average %R is < 0.5% and maximum is < 1.0%. The computation can be performed in FilmStar BASIC, but it's easier to use the Workbook.
Normally <<WbText ..>> requires that the Workbook be open before the Report Generator is activated. This can be confusing in production. An enhancement implemented in DESIGN 2.65.3120 and MEASURE 2.51.1360 allows the Report Generator to open the Hidden Workbook. This is illustrated in the template code below followed by the PDF image (50%) of the final result.
Generating BASIC Code: As mentioned previously, Report Templates are stored in Graph Axes/FILM Archive or Scan Method files. This is convenient, but in some circumstances it might be preferable to generate Report Templates in BASIC code. Click File.. Create BASIC Code in the Report Generator window.
Our final example shows how to assemble a printed coating design catalog. Since we want the same Report Template for various designs we need to override any template already attached to the FILM Archive.
What about FSPlot format? A Report
Template containing BASIC code (as in Embedding BASIC Code) cannot be
inside another BASIC program. Simply add FSPlot formatting code (as copied to
the Clipboard in FSPlot's File.. Create BASIC Code) to Sub Main.
Alternatively, run
PlotConfig.bas before creating reports. Updating Saved Templates: Report Templates are saved in MEASURE/Scantraq Scan Method files (*.scw) and DESIGN FILM Archive (*.faw) or Graph Axes (*.axw) files. A user requested the ability to automatically attach the same template to all scan methods in a given directory. In this way QA technicians need not deal with BASIC macros. The same technique could be utilized in DESIGN for quotes, catalog sheets, etc. BACK UP FILES BEFORE PROCEEDING! Sub Main Sub
AssignTemplate(ByVal f$) MEASURE 2.51.1412 adds BASIC Property DeviceMode which returns device type and scan mode (e.g. "PE 9 %R"). Use this to branch to different AssignTemplate routines according to instrument type. Alternatively, it is possible to branch according to file name, assuming names contain similar information. Press <F1> in the Report Template dialog and note the variety of format settings, including margins. FSPlot graphs utilized in a report must have the same colors, fonts, etc. Since settings are easily modified, consider generating plot setup code to be executed by template action command BasRun before FSPlot, as illustrated in the above code sample. It is also possible to insert the code in the template and execute with BasExec. In that case the short Template = line is replaced by a single long line as follows.
Recall that Sub Main and
End Sub are automatically added by BasExec and that "|" indicates
next line. We did not include PlotColors, PlotTableColors,
PlotTableGrid because the graph is monochromatic and there is no Plot Table.
While the line is lengthy, eliminating the need for a separate BASIC file
simplifies matters. |
Copyright © 2023 FTG Software Associates
Last updated on
January 31, 2023