HomeTechnical Support » Modifying Forms

Modifying Forms

PrintBoss Form Commands #IF/#ElseIf/#Else/#EndIf Messages in this topic - RSS

Nancy
Administrator
Posts: 765


6/23/2011
Nancy
Administrator
Posts: 765
When PrintBoss captures a file or a print job from the accounting software, the PrintBoss Form File (.PBF) is the conductor that controls if and how all the data will be used.

This includes:
o Add background graphics and text to the form
o Place data from the PrintBoss Bank Record
o Select and place graphic/logo/signature files
o Reformat and use data passed by the accounting software
o Add conditions
o Manage copies

The most common conditional commands are documented in Chapter 9 of the PrintBoss Users' Manual. The PrintBoss Users' Manual can be found at: http://216.114.67.7/Support/DynamicSupport/Directory.aspx?Home=manual. There are four PrintBoss commands, that when used in pairs can conditionally process blocks of code.

The commands are:
#If
#ElseIf
#Else
#EndIf

As an example, the following code…

#If [Empty, {EmailTo}]
#Text 1, 1, ‘Arial/9’, “There is no e-mail address”
#EndIf

…is functionally identical to the following line:

#[Empty, {EmailTo}]Text 1, 1, ‘Arial/9’, “There is no e-mail address”

However, the advantage to using an #If statement is that you can set a single condition or series of conditions that will affect as many separate commands as you want in the block without having to repeat the conditional part before each separate command. More importantly you can use the || operator between conditions to seup "OR" logic for the conditions, which you cannot do by just putting the conditions in front of a given command.

The syntax for using the commands is as follows:

#If [Condition]
Command 1
Command 2
…Command X
#ElseIf [Condition]
Command 1
Command 2
….Command Y
#Else [Condition]
Command 1
Command 2
Command Z
#EndIf

Note that only one command is necessary in these blocks, but you can have as many commands as you want. And, wherever you can have one [Condition], you can also have multiple successive conditions, as in:

#If ÷ [Condition1][Condition2][Condition3] ÷
Command 1
Command 2
…Command X
#EndIf

Note that the ÷ symbols or a suitable alternative delimiter character are required around the entire set of conditions for the logic to be handled properly. Without such delimiters, only the first condition will be evaluated.

In this case, the commands will only execute if ALL three of the conditions evaluate to “true,” because the assumed logic for appended conditions with no operators is “AND.”

Alternatively, you can use the || symbol directly between multiple conditions to force “OR” logic, as in:

#If ÷[Condition1]||[Condition2]||[Condition3] ÷
Command1
Command2
…Command X
#EndIf

In this scenario, the commands will be executed if ANY of the three conditions to “true.”


A recent email asked about how to include multiple conditions on the #IF statement:

"The logic in my code is #IF is looking for the PrintBoss Signature File to be in D: E: F: or G:, if the file exists, it should go to “Do something A”, if it does not exists, it should go to “Do Something B”.

Here's my script:

#If FileExists,'D:\BB_JC1676.SIG']||[FileExists,'E:\BB_JC1676.SIG']||[FileExists,'F:\BB_JC1676.SIG']||[FileExists,'G:\BB_JC1676.SIG']

Do something A
#Else

Do something B

#Endif

The problem I have here is if I move the condition [FileExists,'G:\BB_JC1676.SIG'] to the beginning of the line instead of D:\ it works well but if this condition is further on the line after the 'or' (represented by ||), it does not work."

This code goes in “Do something B” even if the key is in the G: drive."

The answer is to this challenge is that any time you have multiple conditions on an #If statement, you must delimit the entire block of conditions with a special character. A delimiting character that we recommend using within PrintBoss is the “divided by” symbol. This PrintBoss delimiter is accessed using the CTRL-apostrophe key within the PrintBoss editor.

So to get the desired result for the emailed example, it should be changed to:

#If ÷[FileExists,'D:\BB_JC1676.SIG']||[FileExists,'E:\BB_JC1676.SIG']||[FileExists,'F:\BB_JC1676.SIG']||[FileExists,'G:\BB_JC1676.SIG']÷

If you don’t delimit the entire “If” block, PrintBoss will only resolve the first condition properly.
edited by Nancy on 6/24/2011
<em>edited by Nancy on 6/24/2011</em>
0 link






Powered by Jitbit Forum 8.3.8.0 © 2006-2013 Jitbit Software