Multi-Line Scripts

You may, on occasion, need to use scripts with multiple lines, especially when a single-line expression is insufficient to properly examine your data and compute the desired results. Because a multi-line script is, for all intents and purposes, a simplified Visual Basic program, you can make it as sophisticated as you need it to be.

Multi-line scripts require the use of assignment operators. This means that the result of any function, expression, or other operation must be assigned to a variable. If you want to assign a value to the object that contains the script, you can assign it to the variable value.

Setting the Variable Called "Value"

Visual Basic scripts in BarTender typically accept data from either the keyboard or a data source file, alter it in some way, and then assign the altered data to a barcode, encoder, or text object. In order to assign this value, a line of Visual Basic beginning with "value =" must appear somewhere in the script (usually, but not necessarily, at the end). On the right side of the equal sign is the value you wish to assign. For example:

value = LEFT(Field("part_number"),5)

This example takes the "part_number" field from the current database record and discards all but the first five characters. Placing this result into the reserved variable "value" assigns it to the object associated with this data source.

Related Topics