Difference between revisions of "MC-Basic:PROGRAM ... END PROGRAM"
(Created page with '{{MC-Basic |SHORT FORM= |SYNTAX= Program<br> ''<nowiki><code to execute></nowiki>''<br> End Program |AVAILABILITY= All versions |DESCRIPTION= The PROGRAM…END…') |
m (1 revision) |
(No difference)
|
Revision as of 16:10, 13 December 2010
The PROGRAM…END PROGRAM keywords are used to delimit the main section of code in a task. Task variables, defined using DIM SHARED, must appear before the Program keyword. Local variables (defined using DIM alone), appear after the Program keyword, but before the code. Subprograms must appear after the End Program keywords.
When a program is loaded into memory (using the LOAD command), it does not start executing until the STARTTASK command is executed. By adding the Continue keyword to the Program keyword, the program automatically starts executing after it is loaded.
When a task reaches End Program, it stops running, but remains loaded in memory. End Program may be replaced by Terminate Program. In this case, the task is automatically unloaded from memory when it finishes.
Syntax
Program
<code to execute>
End Program
Availability
All versions
Scope
Task, Multi-line commands via entry station
Examples
Dim Shared var1 as Long
Program
Dim I As Long
for I = 1 to 10
var1 = var1 + 1
Next I
End Program