Difference between revisions of "MC-Basic:PROGRAM ... END PROGRAM"

From SoftMC-Wiki
Jump to: navigation, search
(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…')
 
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Languages|MC-Basic:PROGRAM_..._END_PROGRAM}}
 +
 
{{MC-Basic
 
{{MC-Basic
 
|SHORT FORM=
 
|SHORT FORM=
Line 38: Line 40:
  
 
|EXAMPLE=
 
|EXAMPLE=
Dim Shared var1 as Long<br>
+
<pre>
 +
Dim Shared var1 as Long
  
Program<br>
+
Program
       Dim I As Long<br>
+
    Dim I As Long
                   for I = 1 to 10<br>
 
                   var1 = var1 + 1<br>
 
       Next I<br>
 
  
 +
    for I = 1 to 10
 +
        var1 = var1 + 1
 +
    Next I
 
End Program
 
End Program
 +
</pre>
  
 
|SEE ALSO=
 
|SEE ALSO=
* [[Axystems:MC-Basic:DIM SHARED ... AS LONG or DOUBLE or STRING|DIM SHARED ... AS LONG or DOUBLE or STRING]]
+
* [[MC-Basic:DIM SHARED ... AS LONG or DOUBLE or STRING|DIM SHARED ... AS LONG or DOUBLE or STRING]]
* [[Axystems:MC-Basic:SUB ... END SUB|SUB ... END SUB]]
+
* [[MC-Basic:SUB ... END SUB|SUB ... END SUB]]
* [[Axystems:MC-Basic:FUNCTION ... END FUNCTION|FUNCTION ... END FUNCTION]]
+
* [[MC-Basic:FUNCTION ... END FUNCTION|FUNCTION ... END FUNCTION]]
  
  
 
}}
 
}}

Latest revision as of 07:58, 10 April 2017

Language: English  • 中文(简体)‎

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

See Also