CAL Variable Commands

CAL has nine variables called V1, V2, ..., V9. These are temporary storage locations you can use to move information between form boxes and other data sources.

Variable names can be substituted in any CAL command. Any item shown in italics in a command description may be replaced by the name of a variable, prefixed with a dollar sign.

For example, MSG message may be either of:

MSG "An explicit message" message explicitly coded into the script
MSG $V2 message taken from variable 2 at run time

You may concatenate variables and variables and literals together in CAL commands. You must add both a leading and trailing dollar sign to the variable name.

For example,


Displays a message box with the value of V2 immediately followed by the value of V1.

Most commands for manipulating variables take an optional variable number as the first argument. If the number is omitted, it is assumed to be 1.

Command Description
SETVAL [v] text Puts the specified text into a variable. 
READVAL [v] filename Reads the contents of a text file into a variable.
WRITEVAL [v] filename Copies the contents of a variable to a file.
INPUT [v] [prompt] Displays a text input dialog, accepts data from the user and stores it in a variable. An optional prompt string is displayed in the box when it appears.
PASSWORD [v] [default] Is the same as INPUT, but displays all characters as asterisks.
GETDATA [v] box Retrieves the contents of a form box (as long as it is not a structure) into a variable; see above for how to identify a box.
PUTDATA box text Copies specified text into a form box. Form names are case-sensitive. Be sure to use the same case as the form box name into which you want to store data.
APPEND ON Determines whether data in a storage location is kept if other data is being moved there.Causes any subsequent data movements to append new data to old.
APPEND OFF Causes old data to be overwritten. This applies to all variable commands except PUTDATA. The default at program startup is APPEND OFF.
APPENDVAL [v] [text] Is a shortcut designed to make it easier to build string values. It is the same as setting APPEND ON, doing a SETVAL, and then restoring APPEND to its original state.
INCREMENT [v] Adds 1 to the value of a variable. Use INCREMENT in loops.
DECREMENT [v] Subtracts 1 from the value of a variable. Use DECREMENT in loops.
LET v v op v
Allows you to perform mathematical operations on variables that contain integer or real-number values. Only one operator per line is supported. It recognizes the following operators:
  • + for addition
  • - for subtraction
  • * for multiplication
  • / for division


Command Action
SETVAL "some text" store text in V1
SETVAL V2 "other text" Store text in V2
READVAL V9 tmpdata.txt Read text from file into V9
APPEND ON Turn on append mode
WRITEVAL output.txt Append contents of V1 to file
SETVAL V2 "append me" Append text to contents of V2
APPEND OFF Turn off append mode
INPUT V2 "enter new data" Prompt and get user input to V2
GETDATA V3 molname Copy data from molname box to V3
PUTDATA molname "benzene" Store given string in molname box
LET V3$V1+ $V4 Sets V3 equal to the value stored in V1 plus the value stored in V4.

2005 CambridgeSoft Corporation. All Rights Reserved. Privacy Statement
Tel  800 315-7300 / 617 588-9300     Fax  617 588-9390     Email
CambridgeSoft Corporation, 100 CambridgePark Drive, Cambridge, MA 02140 USA