Using Strings for Simple IF Statements
- Heidi Adams
- Eric Mohr
Overview
This feature utilizes the VAR1 register to store a sting of text in the STR1 registry. The register can be populated with a database field (surrounded by square brackets [ ]) or static text (surrounded by double quotes " "). The value stored in STR1 can be compared to a static value to create basic IF statements.
It allows the code that "prints" the ticket to choose between two different outputs.
Valid keywords:
- [If STR1 EQ]
- [If STR1 NULL]
- [If VAR1 EQ]
For example; the user would like to print the value stored in database field [MATERIAL USER DATA 5] on the ticket, but only if it is equal to a certain value. If it is not equal, they can choose to print another database field, static text, or nothing at all.
There are basically 5 parts to the command line. The following example is a valid ticket command line.
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] [If STR1 EQ] "True" "Not True"
Use the VAR1 command to set a value in the STR1 registry - VAR1 [MATERIAL USER DATA 5]
When the value is alpha numeric, VAR1 is set to zero (0)
- Declare the database field or text to be printed on the ticket – [MATERIAL USER DATA 5]
- Compare the value stored in the STR1 registry to a static value - [If STR1 EQ] "True"
- If the values are equal, pint only the commands declared at the beginning of the line – [MATERIAL USER DATA 5] and discard the remainder of the format line
- If the values are NOT equal print only the commands after the IF statement – "Not True"
If the values are equal, Interact stops evaluating the print line and prints whatever has been built and discards the remainder of the line. All print commands after the IF statement ([If STR1 EQ "Value"]) are ignored.
If the values are NOT equal, Interact clears all print commands on the line before the IF statement ([If STR1 EQ] "Value"). Only the print commands after the IF statement will be printed– "Not True"
If the string is not built correctly Interact Ticket Emailer will produce the wrong output.
Examples
Example 1: - [If STR1 EQ]
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] [If STR1 EQ] "True" "Not True"
H VAR1 [MATERIAL USER DATA 5]
When Interact sees the VAR1 command it populates the VAR1 and STR1 registers with the value that follows. If the value is a number, both registers are populated. If the value is alpha numeric, the value is placed in the STR1 register and the VAR1 register is set to zero (0).
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] …….
Interact will start building the ticket with the value stored in the [MATERIAL USER DATA 5] database field.
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] [If STR1 EQ] "True"
Interact reads the next bit of information [If STR1 EQ] "True". Interact stops and compares the value set in the STR1 registry to the value it is planning to print on the ticket [MATERIAL USER DATA 5]. If the value it was planning to print, [MATERIAL USER DATA 5], is equal to the value in double quotes "True" Interact will stop building the ticket line and print whatever has been built [MATERIAL USER DATA 5] and ignores the remainder of the format line.
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] [If STR1 EQ] "True" "Not True"
If the value in database field [MATERIAL USER DATA 5] is not equal to the value in double quotes, Interact will clear the format line and print whatever follows the IF statement. In this example Interact will print Not True.
Example 2: - [If STR1 EQ]
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] [If STR1 EQ] "True" [MATERIAL USER DATA 4]
This example contains one difference. When the value in [MATERIAL USER DATA 5] is not equal to 'True" the value in [MATERIAL USER DATA 4] will print on the ticket.
Example 3: [If STR1 EQ]
H VAR1 [MATERIAL USER DATA 5] [MATERIAL USER DATA 5] [If STR1 EQ] "True" [MATERIAL USER DATA 4] "Net Weight: " [Net Weight]
In this example when the value in [MATERIAL USER DATA 5] is equal to "True" only the database field [MATERIAL USER DATA 5] will print. If the value is not equal to 'True" the value in [MATERIAL USER DATA 4] and the text "Net Weight: " and the value stored in database field [Net Weight] will print on the ticket.
Example 4: - [If STR1 NULL]
H VAR1 [MATERIAL USER DATA 5] "This field is empty" [If STR1 NULL] [MATERIAL USER DATA 5]
In this example the VAR1 statement is detected and Interact sets STR1 with the value stored in [MATERIAL USER DATA 5]. Interact continues to build the ticket with the text This field is empty. The [if STR1 NULL] command evaluates the value stored in STR1. If it is empty print only the commands before the IF statement and ignore the rest of the format line. If the value stored in STR1 is not empty, Interact will print the commands after the IF statement, the value stored in [MATERIAL USER DATA 5] for this example.
- Ticket Configuration and Overview
- How to Design a Ticket Ticket Design
- Font and Positioning Commands
- Ticket Extensions
- Ticket Keywords | Flag Fields | Images
- Static Images
- Variables and Calculations
- Ticket Priority and Custom Ticket Designs
- Ticket Emailer
- Printer Setup
- Sample Ticket Designs
- Assigning ticket formats; system default, account specific, truck specific, or truck type
- Import an existing ticket