Assignment Statements

The simple assignment statement in mvBASIC is of the form var = expr. A full list of operators is given in Format, Data, and Expressions. For example, the variable NUMBER can be set to the value 7 with:

NUMBER = 7

Any valid expression can be used in an assignment statement. For example, NUMBER2 can be assigned the value of NUMBER plus 2 with:

NUMBER2 = NUMBER + 2

mvBASIC also supports operator assignment. For example, 2 can be added to the value of NUMBER with:

NUMBER += 2

as a shorthand for:

NUMBER = NUMBER + 2

Accepted operators for operator assignment are:

+

Addition

-

Subtraction

*

Multiplication

/

Division

:

Concatenation

Initializing Variables (CLEAR)

The CLEAR statement acts to initialize all variables to the value 0. It cannot be used to initialize a single variable, however, and initializing all variables to 0 may result in errors due to unassigned variables remaining undiscovered.

Assigning Constants (EQUATE)

The EQUATE statement is used to make a variable functionally equivalent to another or to assign a constant. It cannot be used to assign a variable, since values assigned with an EQUATE statement cannot be reassigned during the program.

The EQUATE statement assigns values at compile time. No operators or functions can be incorporated into an EQUATE statement, with the exception of the CHAR function. Thus, the EQUATE statement can be used to supply a meaningful name for a special character in a program or for an element of a dimensioned array, for example, to equate AM to an attribute mark:

EQUATE AM TO CHAR(254)

or to equate QTY to element 4 of the dimensioned array INVENTORY:

EQUATE QTY TO INVENTORY(4)

See Also

Overview of mvBASIC Statements and Functions

Intrinsic Functions

Internal Program Control

External Program Control

Sending Output to the Screen and Printer

Terminal Input

Dynamic Array Processing

Generalized String Processing

Dimensioned Arrays

Reading and Updating File Items

Reading and Writing Tapes or Floppy Disks

Communications

Execution Locks

Compiler Directives

Miscellaneous Statements and Functions

The Error Message Processor