Examples, Simple subroutine, Nested subroutine – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual
Page 115
Advertising
Publication 1746-RM001A-US-P
Execution Control and Interrupt Support Functions 8-19
Examples
Simple Subroutine
>1
REM EXAMPLE PROGRAM
>10
FOR I = 1 TO 5
>20
GOSUB 100
>30
NEXT I
>40
END
>100 PRINT I
>110 RETURN
READY
>RUN
1
2
3
4
5
READY
>
Nested Subroutine
>1
REM EXAMPLE PROGRAM
>10
FOR I = 1 TO 5
>20
GOSUB 100
>30
NEXT I
>40
END
>100 PRINT I,
>110 GOSUB 200
>120 RETURN
>200 PRINT I*I,
>210 GOSUB 300
>220 RETURN
>300 PRINT I*I*I
>310 RETURN
READY
>RUN
1
1
1
2
4
8
3
9
27
4
16
64
5
25
125
READY
>
Advertising