Evaluate Visual Basic Script expressions

You can use the USER_SYM_EVALVB subroutine in a complex User Symbolic to evaluate Visual Basic Script (VBScript) expressions.

Subroutine name

USER_SYM_EVALVB

Examples of use

  • Create conditions. For example, if there is a next higher term it will be displayed in brackets, if not, nothing will be displayed.

  • Use Javascript to create expressions.

  • Join multiple fields together with a carriage return between each section of data.

  • Perform calculations based on dates or numeric fields.

Argument syntax and parameters

For information about VBScript, please refer to the Microsoft Developer Network (MSDN).

To include Vernon CMS fields in the VBScript expression, enclose the internal field name or Field Mark Count (FMC) of the field inside curly brackets. For example:

{NAME} & ": " & ({USER_SYM_1#N} + {USER_SYM_2#N})

In addition to including the internal field name or FMC of the field, you may also need to include the following (delimited by '#'):

  • The letter N to indicate that the result is expected to be numeric. For example:

    {ITEM_COUNT#N}

  • The letter A to indicate that the result is expected to be text. For example:

    {RECORD_STATUS#A}

  • The letter V to indicate that the expression should operate per value (for multi-valued fields). For example:

    {DDE_FILENAME#VA}

Field conversions

You may also wish to include an optional field conversion for authority, date or currency fields.

For example:

{PROD_PRI_PLACE#VA#DICT}

In this example:

  • PROD_PRI_PLACE is the internal field name for the Production Place field in the Object file.

  • VA indicates that the result is expected to be text, and specifies that if there is more than one entry in the Production Place field the VBScript expression should operate on each entry individually.

  • DICT instructs the system to use the default conversion (as per the dictionary) for this field.

Field conversions can be applied to fields within the expression, as well as to the symbolic result (by entering the conversion in the Conversion field). A conversion is only required at field level if the field needs to be converted before the expression is evaluated.

Field conversions must not contain any '{}' or '#' characters.

Cond() function

The Cond() function evaluates conditional expressions. It returns one of two options based on a test. You specify the condition. If the condition is met, option one will be returned. If the condition is not met, option two will be returned.

The basic structure of a conditional expression is as follows:

Cond(test, option1, option2)

In this example, test, option1 and option2 can be any valid EvalVB expressions.

For example, you may want to create a User Symbolic to display Artist/Maker Place of Birth, with the Next Higher Term in brackets next to the term. For example, Portland (Oregon). However, if the Place of Birth has no Next Higher Term, you don't want empty brackets, such as United States of America ().

You could create a conditional expression to check the Next Higher Term field for data. If the field contains data, it will be displayed between brackets. If the field does not contain data, nothing will be displayed. The argument would be as follows:

{AU_NAME} & Cond({AU_NEXT_TERM#A}, " (" & {AU_NEXT_TERM#A#DICT} & ")", "")

In this example:

  • test is {AU_NEXT_TERM#A}

  • option1 is " (" & {AU_NEXT_TERM#A#DICT} & ")"

  • option2 is ""

No conversion is required for this test as the expression is simply checking for the presence or absence of data. If your test relied on specific data, you would need to convert the field from its internal format, for example, {AU_NAME} & Cond({AU_NEXT_TERM#A#DICT} = "United States of America".

Complex scripts

To use another language (such as JavaScript) or to use supporting script subroutines, save the subroutines as a text file and call it in the expression. For example:

LOAD|SCRIPTS\USERSYMx.EVL|userSymX("{FIELD}", "{FIELD}" etc.)

where the source code for userSymX() is in Wincoll\SCRIPTS\USERSYMx.EVL and FIELD is a Vernon CMS internal field name or FMC.