Vbscript Item Does Not Evaluate Correctly. Follow

Legacy Poster

I'm on 10.1 SR4, Automation.  I have a label with text fields as follows:

  Text1 is looked up from a database

  Text2 is calculated using a VBscript function on Text1

  Text3 is calculated using a VBscript function on Text2


Text1 and 2 evaluate and print correctly.  Text3 does not.  It always prints the default value of Text1.


I was able to work around this by putting both functions together and eliminating Text3.  However, I'm curious why this doesn't work.  Is VBscript within BarTender not recursive?



Legacy Poster
Comment actions Permalink

We're using 10 SR4 and I just tested this without any issue.


Text1 is assigned 1.

Text2 has vbscript referencing Text1 + 10.

Text3 has vbscript referencing Text2 + 10.


If I change Text1 the other two update correctly.

Legacy Poster
Comment actions Permalink

This excerpt from the BT manual might also shed some light on your issue:



Forcing Reference to Fields and Share Names

In order for BarTender to determine the best

time to run your scripts during a print job and which data file fields it will
need to access, it examines the structure of your template and does a test run
of your scripts. Among other factors, BarTender
considers when and how any database fields and data source names are used.

The Problem with Conditional Execution

Conditional statements execute different "branches" of code, depending on how
a conditional expression is evaluated. Accordingly, some code may not get
executed, depending on the conditions at the time of the evaluation. This can
cause a problem if a reference to a field or share name happens to be in code
that gets skipped during BarTender's test run of
its scripts. If the associated conditional statement evaluates differently at
print-time and causes the field or share name to be referenced, and it didn’t
get referenced during the previous test run, the script may not run at the most
efficient time and may even fail.

Two Different Forcing Functions

The Script Assistant
includes two functions that force a script to reference a data file field
or data source name. These functions don’t change or assign any values, they
simply force BarTender to notice the presence of an
item that could be missed during the test run of a script. This ensures that
BarTender will establish links to all of the
necessary data fields and that your scripts will be executed in response to the
appropriate events at print time.

To find the following two functions in the Script Assistant, double-click on
Functions and then Declarations in the Category option.
Then double-click on the desired reference function and field or share name in
the Names option. The reference functions are best inserted into the
beginning of your script before any conditional statements.

To Force Reference to a Data File Field


If the document is set up to read data from a regular text
file, you will specify a field number. When reading from a database, you
will specify a field name. Unless the field name itself is contained in a
variable, be sure to put the name in quotes, such as

To Force Reference to a Shared Data Source


If you have given any data sources in the template a share
name, you can force reference to them as shown above. (Unless the share name is
stored in a variable, be sure to put quotes around it.)

Please sign in to leave a comment.