RBASIC™ Commands
RBASIC program lines consist of commands. The program executes one program line after another. The program flow can be changed using labels and branching commands such as GOTO or GOSUB. For example, the following program
GOTO there will greet you "Have a nice day." because the "You will never know" message command will get skipped by the GOTO command targeting the label "there". Note that labels have the "@" symbol in front of them, or you can use the keyword LABEL like this:
GOTO there or, you can include the "@" symbol in both GOTO and LABEL commands like this:
GOTO @there Variable assignment LET a=1 This assigns the value 1 to variable a. The keyword LET can be (and usually is) omitted. The following two lines
LET a=1 are equivalent. Array definition RBASIC does support multidimensional arrays. These need to be defined before any assignment to their elements can be made. Examples:
DIM a(10,10) Prints a line onto console. Example: PRINT a$, or PRINT "hello" DISP Same as PRINT, but doesn't move to the next line. Repeated using DISP writes text to the same line. Very handy to see real-time signal strength changes! Program Execution Commands LABEL Places a label into script (target of GOTO and GOSUB commands). It is not necessary to use this if the @ sign precedes the label. For example,
LABEL x1 are all equivalent. GOTO Changes the execution flow (jumps to the label). For example,
GOTO x1 are equivalent. GOSUB Executes a subroutine it is similar to GOTO, but stores the return address onto stack, and returns to where it was called after executing the RETURN command. RETURN Jump to the last return address in the stack and removes the stack entry. FOR Define a program loop. This expects the user to define the control variable, its starting and end values, and optionally the step value. (If no step value is given, 1 is implied.) Examples:
FOR var=0 to 10 NEXT End of loop specified by FOR command. Example: NEXT var IF Conditional branching. If the expression following IF is true, commands following THEN are executed. If it is false then execution continues after the optional ELSE statement, or on the next line. Examples:
IF signalstrength>50 then PRINT "signal found" REM Remark. Execution continues on the next line. Or you can just use the '#' sign at the start of the line. Examples:
REM this is not executed BEEP Gives one beep. STOP Breakpoint. Pauses execution and shows the STOP message. Execution can be restarted from the point where it stopped by clicking on the Run or Step button. DELAY Pauses execution for desired ammount of time (in ms). Doesn't show any message. Example: DELAY (1000) delays execution for one second. START Starts an executable or opens a document in the default viewer
START ("c:\program.exe") END Ends the program. Not compulsory if the program ends with the last line. Handy if the main body of the program is followed by subroutines (to ensure that the program does not "fall" into a subroutine). Example:
GOSUB @mysubroutine Input/Output Commands INPUT
Assigns a variable with a number or text, typed by the user into the Console input line.
Example: GET Similar to INPUT, but opens a separate input dialog box. Example: GET "Enter a number", variable Note that when the GET command is canceled, the program is paused. After re-starting the execution with Run or Step, it continues by repeating the dialog. MESSAGE Shows a system message and waits for pressing a button. Example: MESSAGE "Press a button."
|