BTRON MicroScript Reference Manual

Control


_____
SLEEP
Syntax
Function
_____This waits up to a specified time. The time expression is specified in units of milliseconds (one second is 1,000 milliseconds). The range of 0`86400 x 1000 (24 hours) is valid.
_____The actual resolution depends on the system (in the case of TiPO the resolution is 50 milliseconds).
Errors that Occur at Startup Time
Please specify the integer item
Please specify the integer in specifying the time.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ Waiting has terminated based on the elapsing of the time.
2_____ Waiting has been forcibly released based on a BREAK statement in another thread.
110

I Reference Section

WAIT
Syntax
Function
_____This waits until the value of a conditional expression becomes other than 0.
_____The timeout expression specifies in units of seconds. This is a range of 0`86400 (24 hours). In a case where the timeout expression is 0, waiting terminates immediately. In a case where the timeout expression has been omitted, waiting will continue until either a condition is established, or there is a BREAK from another thread.
_____Whether the termination of waiting is something based on the establishment of a condition, or something based on a timeout can be judged by the system variable $ERR.
Errors that Occur at Startup Time
Please specify the integer item
Please specify the integer item in the timeout expression.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ Waiting has terminated based on the establishment of a condition.
1_____ Waiting has terminated based on a timeout.
2_____ Waiting has been forcibly released based on a BREAK statement in another thread.

111

_____
IF`ELSEIF`ELSE`ENDIF
Syntax
Function
_____The IF statement judges whether or not a condition has been established, and then based on that, it branches the execution of the script. We call something that influences the execution of a script in this manner by means of conditions control syntax; there are SWITCH`CASE`DEFAULT`ENDCASE; WHILE`ENDWHILE, which carries out recursion; and REPEAT`ENDREPEAT.
_____The condition of the IF statement is specified with an expression. The typical one is
_____
IF Variable>5
_____
where, when the variable is greater than 5, the value becomes 1. When the value of the expression is 1 (actually, it's fine if it isn't 0), the IF statement executes from the next statement up to ELSE or ELSEIF (if there is no ELSE or ELSEIF, up to ENDIF; execution will continue from the statement following ENDIF, without anything being executed from ELSE or ELSEIF up to ENDIF). In a case where the variable is less than 5 and the value of the expression becomes 0, nothing will be executed from the IF statement up to ELSE or ELSEIF; from ELSE up to ENDIF, or ELSEIF, will be executed (if there is no ELSE or ELSEIF, execution will continue from the statement following ENDIF, without up to ENDIF being executed).
_____In the IF`ELSEIF`ELSE`ENDIF span, we can insert other control syntax (IF`ELSEIF`ELSE`ENDIF, SWITCH`CASE`DEFAULT`ENDCASE, WHILE`ENDWHILE, REPEAT`ENDREPEAT), and, moreover, in the span of other control syntax also, we can insert IF`ELSEIF`ELSE`ENDIF; but, for example, a description such as
_____
IF Variable>5
WHILE Variable>2
ELSE
ENDWHILE
ENDIF
_____
will become an error.
_____Furthermore, in comparing the contents of array variables, it is necessary to use at the same time the acmp function and the scmp function. For details, please refer to = (p. 23), acmp (p. 198), scmp (p. 224).
Errors that Occur at Startup Time
The IF`ENDIF structure is illegal
IF`ELSEIF`ELSE`ENDIF are not in correspondence. Please confirm whether there isn't an ELSEIF, ELSE, or ENDIF, even though there isn't an IF; or whether there isn't something like a corresponding ELSEIF inside an REPEAT`ENDREPEAT, even though the IF is outside the REPEAT`ENDREPEAT.
The control structure beginning from the nth line is not closed
Although there is an IF, there is no ENDIF. Please confirm whether there is an ENDIF after the IF.
The REPEAT`ENDREPEAT structure is illegal
The WHILE`ENDWHILE structure is illegal
The SWITCH`ENDCASE structure is illegal
REPEAT`ENDREPEAT, etc., are divided into parts by means of IF. Please confirm whether there isn't a structure of the type where REPEAT is inside IF, or ENDREPEAT is inside ELSE.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.
112, 113

_____
ELSEIF
Syntax
Function
_____When the condition of the immediately preceding IF is not established, this executes IF again. Concerning the specification of conditions, please refer to the item on IF (p. 112).
_____In a case where the condition of the immediately preceding IF is not established, and where the condition of the ELSEIF is established, from this statement up to ELSE or ELSEIF (in a case where there is no ELSE or ELSEIF, up to ENDIF) will be executed, and after that, rearward from the ENDIF will be executed.
_____In a case where the condition of the immediately preceding IF is not established, and where the condition of the ELSEIF is not established, from this statement up to ELSE or ELSEIF (in a case where there is no ELSE or ELSEIF, up to ENDIF) will be executed, and after that, rearward from the ENDIF will be executed.
_____Even if you do not use ELSEIF, you can create a script that possesses the same function; in the manner of,
_____
IF
`
ELSE
IF
`
ELSE
`
ENDIF
ENDIF
_____
multiple ENDIFs are necessary. When we use ELSEIF, we can write it in the manner of:
_____
IF
`
ELSEIF
`
ELSE
`
ENDIF
_____
Errors that Occur at Startup Time
The IF`ENDIF structure is illegal
IF and ELSEIF, ELSEIF and ENDIF are not in correspondence. Please confirm whether there isn't an ELSEIF, even though there isn't an IF; or whether there isn't an ELSEIF after an ELSE. Please confirm also whether there isn't something like a corresponding ELSEIF inside an REPEAT`ENDREPEAT, even though the IF lies outside the REPEAT`ENDREPEAT.
The control structure beginning from the nth line is not closed
Although there is an IF, there is no ENDIF. Please confirm whether there is an ENDIF after the ELSEIF.
The REPEAT`ENDREPEAT structure is illegal
The WHILE`ENDWHILE structure is illegal
The SWITCH`ENDCASE structure is illegal
REPEAT`ENDREPEAT, etc., are divided into parts by means of ELSEIF. Please confirm whether there isn't a structure of the type where REPEAT is inside IF, or ENDREPEAT is inside ELSEIF.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.
114, 115

_____
ELSE
Syntax
Function
_____When the condition of the immediately preceding IF or ELSEIF is not established, from this statement up to ENDIF is executed. In a case where the condition of the immediately preceding IF or ELSEIF is established, ELSE`ENDIF will not be executed. For details, please refer to the item on IF and ELSEIF (p. 112).
Errors that Occur at Startup Time
The IF`ENDIF structure is illegal
IF, ELSEIF, and ELSE are not in correspondence. Please confirm whether there isn't something like an ELSE, even though there isn't an IF or ELSEIF; or, continuing on, there is an ELSE, even though there is no IF or ELSEIF after an ELSE. Also please confirm whether there isn't a corresponding ELSE inside REPEAT`ENDREPEAT, even though the IF is outside the REPEAT`ENDREPEAT.
The control structure beginning from the nth line is not closed
Although there is an IF, there is no ENDIF. Please confirm whether there is an ENDIF after the ELSE.
The REPEAT`ENDREPEAT structure is illegal
The WHILE`ENDWHILE structure is illegal
The SWITCH`ENDCASE structure is illegal
REPEAT`ENDREPEAT, etc., are divided into parts by means of ELSE. Please confirm whether there isn't a structure of the type where REPEAT is inside IF, or ENDREPEAT is inside ELSE.
116

I Reference Section

ENDIF
Syntax
Function
_____This specifies the end of IF, ELSE, and ELSEIF. From this statement forward will be executed without regard to the conditions of IF or ELSEIF. For details, please refer to the item on IF and ELSEIF (p. 112).
Errors that Occur at Startup Time
The IF`ENDIF structure is illegal
IF, ELSE, ELSEIF, and ENDIF are not in correspondence. Please confirm whether there isn't an ENDIF, even though there isn't an IF; or whether there isn't an ENDIF inside an REPEAT`ENDREPEAT, even though the IF lies outside the REPEAT`ENDREPEAT. Furthermore, in a case such as IF`ELSEIF`ENDIF, please confirm also whether you haven't written ENDIF two times.
The REPEAT`ENDREPEAT structure is illegal
The WHILE`ENDWHILE structure is illegal
The SWITCH`ENDCASE structure is illegal
REPEAT`ENDREPEAT, etc., are divided into parts by means of ENDIF. Please confirm whether there isn't a structure of the type where REPEAT is inside IF, or ENDREPEAT is outside IF.

117

_____
BREAK
Syntax
Function
_____In a case where a specified thread is in the process of executing REPEAT`ENDREPEAT, WHILE`ENDWHILE, or SWITCH`ENDCASE., this forcibly makes execution escape one step. In a case where processing is in a waiting state by means of SLEEP, WAIT, VWAIT, RSWAIT, this forcibly makes waiting terminate.
_____In the specification of the thread that will become the target, we use a procedure name (a procedure name used in EXECUTE) or a procedure number expression. You can specify multiple threads as targets for termination.
_____In a case where you have omitted the target thread, the REPEAT`ENDREPEAT, WHILE`ENDWHILE, or SWITCH`ENDCASE of self itself will escape one step.
_____You cannot specify self itself for the target thread (it will be ignored). Even in a case where the procedure of self itself has undergone multi-startup, the effects of the BREAK statement will be only on the threads outside of self.
_____In the case where it is something in which a thread specified in procedure name or symbol variable has performed multi-startup, the effects of the BREAK statement will be in all the threads that have started up from the specified procedure.
Errors that Occur at Startup Time
Please specify the procedure or the procedure number
In the specification of the thread, please specify a procedure or a procedure number.
Because this is external to the control structure, it becomes invalid
A BREAK statement without a thread specification is valid only inside REPEAT`ENDREPEAT, WHILE`ENDWHILE, or SWITCH`ENDCASE.
118

I Reference Section

CONTINUE
Syntax
Function
_____This repeats one more time a loop presently being executed. It is valid for REPEAT`ENDREPEAT, or WHILE`ENDWHILE.
_____In a case where you have used the CONTINUE statement in regard to REPEAT`ENDREPEAT, the extent from the CONTINUE statement to the ENDREPEAT statement will be skipped, and execution will enter the next loop (in a case where it is the last in the number of repetitions, execution will escape the loop). In a case where you have used the CONTINUE statement in regard to WHILE`ENDWHILE, the extent from the CONTINUE statement to the ENDWHILE statement will be skipped, and execution will enter the next loop (at this time, in a case where the condition specified in the WHILE statement is not established, execution will escape the loop).
_____When we use the BREAK statement inside the SWITCH statement, execution ends up escaping from SWITCH`ENDCASE, but when we use the CONTINUE statement inside the SWITCH statement, execution ends up repeating the external loop of the SWITCH statement. By utilizing this, we can use it in the following manner.
_____
REPEAT
SWITCH Character_String [Location]
CASE 0
BREAK
DEFAULT
Location=Location+1
CONTINUE
ENDCASE
BREAK
ENDREPEAT
_____
_____When we execute CONTINUE inside SWITCH`ENDCASE, the loop will continue without rearward from ENDCASE being executed. On the other hand, when we escape from inside SWITCH`ENDCASE with BREAK, etc., we escape from REPEAT`ENDREPEAT by means of the BREAK immediately after ENDCASE. By means of this, we can escape from the loop inside SWITCH`ENDCASE.
Errors that Occur at Startup Time
Because this is external to the control structure, it becomes invalid
A CONTINUE statement is valid only inside REPEAT`ENDREPEAT, or WHILE`ENDWHILE.

119, 120

I Reference Section

SWITCH`CASE`DEFAULT`ENDCASE
Syntax
Function
_____After comparing in description order the CASE statements up to the ENDCASE statement they are in opposition to, this goes on to execute a script below from a CASE statement with the same value. Even if there are CASE statements in the middle, it will execute the script corresponding to the CASE statement, without an evaluation of the CASE statement itself being carried out. Similarly, a script corresponding to the DEFAULT statement also will be executed. In a case where we would like to execute only processing corresponding to a particular CASE statement, we use the BREAK statement (without an argument). When we use the BREAK statement, we can exit to that after the corresponding ENDCASE.
_____In a case where there is no CASE statement with the same value, and there is a DEFAULT statement, we execute what follows the DEFAULT. In between SWITCH`ENDCASE, only one DEFAULT statement can be described at the end of the CASE statements.
Errors that Occur at Startup Time
The control structure that begins from the nth line is not closed
There is no ENDCASE statement corresponding to the SWITCH statement.
The SWITCH`ENDCASE structure is illegal
The DEFAULT statement cannot be described before a CASE statement.
The DEFAULT statement can be used only once inside SWITCH`ENDCASE.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.

121

_____
CASE
Syntax
Function
_____This is used inside SWITCH`ENDCASE. In a case where the SWITCH statement expression and a CASE statement expression take the same value, the script will be executed from after the CASE statement. In a case where they are not the same, the script up to the next CASE statement or the DEFAULT statement will not be executed.
_____Multiple CASE statements can be used inside one SWITCH`ENDCASE. The CASE statement expressions will be evaluated in order from the top. In a case where the value of one CASE expression and the value of the SWITCH expression match, the CASE statements up to the ENDCASE statement that follows will not be evaluated (the same operation as if the CASE statements do not exist is performed).
_____Normally, we make it so that we can escape from SWITCH`ENDCASE by using a BREAK statement at the end of the processing contents corresponding to one CASE statement.
_____Please refer also to the explanation of the SWITCH statement (p. 121).
Errors that Occur at Startup Time
The SWITCH`ENDCASE structure is illegal
The CASE statement can be used only inside SWITCH`ENDCASE.
122

I Reference Section

DEFAULT
Syntax
Function
_____This is used inside SWITCH`ENDCASE. In a case where all the CASE statement expressions are not the same value as the SWITCH statement expression, the contents following the DEFAULT statement up to the ENDCASE statement will be executed. Moreover, when a CASE statement expression is the same as the SWITCH statement expression, even in a case of having arrived up to the DEFAULT statement without escaping control through a BREAK statement from a CASE statement, the contents up to ENDCASE will be executed.
_____The DEFAULT statement can be used only once at the end, inside SWITCH`ENDCASE.
_____Please refer also to the SWITCH statement (p. 121).
Errors that Occur at Startup Time
The SWITCH`ENDCASE structure is illegal
The DEFAULT statement can be used only inside SWITCH`ENDCASE.
123

_____
ENDCASE
Syntax
Function
_____This is used in opposition to the SWITCH statement, and it shows the termination of SWITCH`ENDCASE.
_____Please refer also to the explanation of the SWITCH statement (p. 121).
Errors that Occur at Startup Time
The SWITCH`ENDCASE structure is illegal
There is no SWITCH statement corresponding to the ENDCASE statement.
124

I Reference Section

REPEAT
Syntax
Function
_____This executes just the number of repetitions specified in the span up to the ENDREPEAT statement.
_____The expression for the number of repetitions takes 1`maximum integer value, and we can reference the number of repetitions by means of the system variable $CNT. In a case where the number of repetitions has been omitted, there will be endless repetition. In a case where 0 has been specified in the expression for the number of repetitions, the program up to ENDREPEAT will not execute even once.
_____By using a BREAK statement in the REPEAT`ENDREPEAT span, we can terminate a loop. By using a CONTINUE statement in the REPEAT`ENDREPEAT span, we can continue a loop without executing up to the following ENDREPEAT.
_____By setting a value in $CNT, we can forcibly change the number of repetitions (where we can set a value in $CNT is only in the REPEAT`ENDREPEAT span; the value of $CNT possesses meaning only in the REPEAT`ENDREPEAT span).
_____It is possible to nest REPEAT`ENDREPEAT, and $CNT shows the number of times of the corresponding loop. There are no cases in which the $CNT of an external loop will be modified by the execution of an internal loop.
Errors that Occur at Startup Time
The control structure beginning from the nth line is not closed
The corresponding ENDREPEAT statement does not exist.
Please specify the integer item
Please specify the integer item for the number of repetitions.
Errors that Occur During Execution (only in the case of DEBUG 1; refer to p. 39)
There was an illegal REPEAT count value
Please specify the correct integer value for the number of times of the repetition.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.

125

_____
ENDREPEAT
Syntax
Function
_____This is used in combination with the REPEAT statement. Concerning the operation of REPEAT`ENDREPEAT, please refer to the REPEAT statement (p. 125).
Errors that Occur at Startup Time
The REPEAT`ENDREPEAT structure is illegal
The corresponding REPEAT statement does not exist.
126

I Reference Section

WHILE
Syntax
Function
_____This executes recursively the span up to the ENDWHILE statement while the conditional expression is not 0. The conditional expression will be checked at each time of a loop. In a case where the conditional expression is 0 from the beginning, the loop will not execute even once.
_____By using a BREAK statement in the WHILE`ENDWHILE span, we can terminate a loop. By using a CONTINUE statement in the WHILE`ENDWHILE span, we can continue from the beginning of a loop without executing up to the following ENDWHILE.
Errors that Occur at Startup Time
The control structure beginning from the nth line is not closed
The corresponding ENDWHILE statement does not exist.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.

127

_____
ENDWHILE
Syntax
Function
_____This is used in combination with the WHILE statement. Concerning the operation of WHILE`ENDWHILE, please refer to the WHILE statement (p. 127).
Errors that Occur at Startup Time
The WHILE`ENDWHILE structure is not closed
The corresponding WHILE statement does not exist.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.
128

I Reference Section

CALL
Syntax
Function
_____This executes a procedure defined in FUNC, ACTION, or MACTION. Whichever the procedure, FUNC, ACTION, or MACTION, it waits until termination of the procedure.
_____In the specification of a procedure that makes a call, not only do we directly describe the procedure name, we can describe symbol variables that reference the procedure.
_____It is possible to specify up to 256 arguments (array sections cannot be specified). In the procedure of the CALL destination, we can make references with defined argument names.
_____A value through which a procedure called up by the CALL statement returns will be ignored. For procedure calls in a case where you do not specify substitution of the return value by means of the SET statement, the CALL statement becomes necessary.
_____For procedures that execute with the CALL statement, the procedure numbers (refer to $TID on p. 190) become the same, because they are executed through an extension of the called procedure.
Errors that Occur at Startup Time
Please specify the procedure
Please specify a procedure name or a variable that references a procedure in the spot for the procedure name.
An array section cannot be specified
You cannot specify an array section in the argument expression.
Errors that Occur During Execution (only in the case of DEBUG 1; refer to p. 39)
There was an illegal procedure call
The symbol variable specified in the spot of the procedure name does not reference a procedure.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.

129

_____
EXECUTE
Syntax
Function
_____This executes procedures defined in ACTION or MACTION.
_____Multiple procedures can be described, but you can hand over an argument only to the last specified procedure. It is possible to specify up to 256 arguments. In a procedure at the EXECUTE destination, we can make references with defined argument names.
_____In the specification of a procedure that makes a call, not only do we directly describe the procedure name, we can describe symbol variables that reference the procedure.
_____Differing with the CALL statement, the call-up source procedure and the procedure at the call-up destination are executed in parallel, because the call-up source procedure continues processing without waiting for the termination of the procedure at the EXECUTE destination.
_____In a case where a procedure defined with ACTION is in the process of execution, it will be ignored, because multi-startup is not possible. In the case of a procedure defined with MACTION, there will be startup in multiple.
_____In a case where you have specified variable names, the procedure number for the procedure specified last will be stored. A procedure number is a unique number assigned at the time of procedure execution, and when we utilize this, we can distinguish individual threads, even in a case where we have started up a single procedure in multiple.
_____Furthermore, the self procedure number can be obtained with $TID.
Errors that Occur at Startup Time
Please specify the procedure
Please specify a procedure name or a variable that references a procedure in the spot for the procedure name.
This is an illegal item that cannot be interpreted
You cannot specify an argument outside of the last procedure.
An array section cannot be specified
You cannot specify an array section in the argument expression.
The setting of a value is not possible in this item
Please specify a writable variable in the variable that stores the procedure number.
Errors that Occur During Execution (only in the case of DEBUG 1; refer to p. 39)
There was an item that is not a script
An item that is not a procedure has been specified in the spot for a procedure name.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.
130

I Reference Section

SUSPEND
Syntax
Function
_____This waits until the execution of a specified thread terminates. In a case where you have specified multiple threads, it waits until all the threads have terminated. In a case where threads have done a multi-startup for a procedure name, it waits until all the threads that have done a multi-startup have terminated.
_____In the specification of a thread, we can use a procedure name or a procedure number expression. When you have omitted the specification of a thread, all the threads outside of self become targets. Self itself will not be included in targets for waiting.
_____The timeout expression is specified in units of seconds. The range of 0`86400 (24 hours) is valid. If you specify a timeout expression, when the specified time has elapsed, waiting will terminate, even if the thread has not terminated. Whether the cause of the termination of waiting is a timeout or thread termination can be judged with the system variable $ERR.
Errors that Occur at Startup Time
Please specify the procedure or a procedure number
Please carry out specification of the thread with a procedure name, a symbol variable that references a procedure name, or a procedure number expression.
Please specify the integer item
Please specify the integer item in the timeout expression.
Errors that Occur During Execution (only in the case of DEBUG 1; refer to p. 39)
There was an item that is not a script
An illegal item has been included in the specification of a thread.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ Waiting has terminated based on the termination of the specified thread.
1_____ Waiting has been forcibly released based on a BREAK statement in another thread.
2_____ Waiting has terminated based on a timeout.

131

_____
TERMINATE
Syntax
Function
_____This forcibly terminates execution of a specified thread. In a case where the specification of the thread has been omitted, this forcibly terminates all threads in the process of execution outside of the self.
_____In the specification of the thread that will become the target, we use the procedure name (the procedure name specified in the EXECUTE statement) or a procedure number expression.
_____We can specify multiple threads as termination targets. Even if we specify the procedure number of a thread that (itself) is executing the TERMINATE statement, it will be ignored.
_____In the case of something where a thread specified in a procedure name or symbol variable is carrying out multi-startup, there will be an effect of the TERMINATE statement to all the threads that have started up from the specified procedure.
Errors that Occur at Startup Time
Please specify the procedure name or a procedure number
In the specification of the termination target thread, please specify a procedure name or a procedure number.
Errors that Are Stored in $ERR (in regard to $ERR, refer to p. 170)
0_____ When we execute this statement, 0 gets loaded.
132

I Reference Section

EXIT
Syntax
Function
_____This terminates the execution of a self procedure.
_____The value of a procedure in which the procedure returns to the call-up source is specified in the EXIT statement. This terminates the procedure, and returns as a procedure value the value of an expression. When we have omitted the expression, or in a case where the procedure has terminated with END, it returns 0.
_____We can return a numerical value or a symbol, but we cannot return an array section or multiple values. Also, in a self procedure, we cannot hand over an array variable that has been declared in LOCAL.
Errors that Occur at Startup Time
An array section cannot be specified
An array section cannot be specified in the expression.

133

_____
FINISH
Syntax
Function
____ This terminates MicroScript and closes the window. There is the same effect as termination based on double clicking a pictogram or terminating via a menu operation.
_____In a case where an EPILOGUE procedure exists, it executes immediately prior to the closing of the window.
_____Because there is no such thing as a window opened by means of a VOPEN statement automatically being closed, in accordance with need, it will be necessary to explicitly execute a VCLOSE statement inside something such as an EPILOGUE procedure.
134


The above contents of BTRON MicroScript Reference Manual were translated and loaded onto this Web page with the permission of Personal Media Corporation.

Copyright (c) 1997 Personal Media Corporation

Copyright (c) 2010 Sakamura Laboratory, University Museum, University of Tokyo