Next, Next -9, Purpose – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 93: Syntax

Advertising
background image

Publication 1746-RM001A-US-P

Control Functions 7-9

Example 2

You may execute multiple statements following the THEN or ELSE if you use a
colon to separate them.

>30 IF A<>10 THEN PRINT A : GOTO 150 ELSE 10

>30 IF A<>10 PRINT A : GOTO 150 ELSE 10

In these examples, if A does not equal 10, then both PRINT A and GOTO 150 are
executed. If A equals 10, then control passes to 10.

Example 3

You may omit the ELSE statement. If you omit the ELSE statement control passes
to the next statement.

>1

REM EXAMPLE PROGRAM

>20 IF A=10 THEN 40

>30 PRINT A

In this example, if A equals 10 then control passes to line number 40. If A does not
equal 10, line number 30 is executed.

NEXT

Purpose

Use the NEXT statement to return the FOR-TO-(STEP)-NEXT loop to the
beginning of the loop and add the value of the index increment to the index. The
current index value is then compared to the index limit to determine if another
loop should be performed.

Syntax

NEXT

Advertising