Let -5, Syntax, Examples – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 81: Purpose

Advertising
background image

Publication 1746-RM001A-US-P

Assignment Functions 6-5

Once a variable is dimensioned in a program it may not be re-dimensioned. An
attempt to re-dimension an array causes an array size error that causes the module
to enter the Command mode.

If an array variable is used that was not dimensioned by a DIM statement, BASIC
assigns a default value of 10 to the array size. All arrays are set equal to zero when
the RUN command, NEW command or the CLEAR statement is executed.

The number of bytes allocated for an array is six times the array size plus one
(6

(array size + 1)). For example, the array A (100) requires 606 bytes of storage.

Memory size usually limits the size of a dimensioned array.

Syntax

DIM

Examples

More than one variable can be dimensioned by a single DIM statement.

>

1

REM EXAMPLE PROGRAM

>10 DIM A(25), C(15), A1(20)

Error on attempt to re-dimension array:

>1

REM EXAMPLE PROGRAM

>10 A(5) = 10 : REM BASIC ASSIGNS DEFAULT OF 10 TO ARRAY A

>20 DIM A(5) : REM ARRAY RE-DIMENSION ERROR

>

READY

>RUN

ERROR: ARRAY SIZE - IN LINE

20

20

DIM A(5) : REM ARRAY RE-DIMENSION ERROR

---------------X

READY

>

LET

Purpose

Use the LET statement to assign a variable to the value of an expression.

Syntax

LET [var] = [expr]

Advertising