Output to a File Using Expressions

In the Output Configuration dialog box (File | Printing | Report Window Print Setup), from the Report tab, you can use expressions in the File box. With this functionality, you can use your measurement routine code along with the Output Configuration dialog box to dynamically change the destination directory for the output file.

For example, suppose two users, John and Amy, want to send the same measurement routine's inspection report to an existing subdirectory based off of the user name. Instead of opening the Output Configuration dialog box for each user and changing the destination directory and the name of the report, you can have the user type their name into a Comment and then use assignment and flow control commands to store the different destination directories and report names in a variable, like this:

C1         =COMMENT/INPUT,YES,Type your name:

            IF/C1.INPUT=="John"

            ASSIGN/VAR_FILENAME="C:\\inspectionreports\\John\\John.rtf "

            COMMENT/OPER,NO,VAR_FILENAME

            END_IF/

            ELSE_IF/C1.INPUT=="Amy"

            ASSIGN/VAR_FILENAME="C:\\inpectionreports\\Amy\\Amy.rtf"

            COMMENT/OPER,NO,VAR_FILENAME

            END_ELSEIF/

            ELSE/

            ASSIGN/VAR_FILENAME="C:\\inspectionreports\\"+C1.INPUT+".rtf"

            COMMENT/OPER,NO,VAR_FILENAME

            END_ELSE/

Then inside the File box, on the Report tab of the Output Configuration dialog box, you can type the VAR_FILENAME variable as shown here:

VAR_FILENAME in File box

VAR_FILENAME in File box

Thereafter, whenever you execute the measurement routine, if John is the user, the report John.rtf is saved to his directory; if Amy is the user, Amy.rtf is saved to her directory; if another user types his or her name, it goes to the default C:\Inspectionreports\ directory.