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
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:
or, you can include the "@" symbol in both GOTO and LABEL commands like this:
This assigns the value 1 to variable a. The keyword LET can be (and usually is) omitted. The following two lines
RBASIC does support multidimensional arrays. These need to be defined before any assignment to their elements can be made.
Prints a line onto console. Example: PRINT a$, or PRINT "hello"
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
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,
are all equivalent.
Changes the execution flow (jumps to the label). For example,
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.
Jump to the last return address in the stack and removes the stack entry.
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
End of loop specified by FOR command. Example:
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"
Remark. Execution continues on the next line. Or you can just use the '#' sign at the start of the line.
REM this is not executed
Gives one beep.
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.
Pauses execution for desired ammount of time (in ms). Doesn't show any message.
delays execution for one second.
Starts an executable or opens a document in the default viewer
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:
Assigns a variable with a number or text, typed by the user into the Console input line.
Similar to INPUT, but opens a separate input dialog box.
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.
Shows a system message and waits for pressing a button.
MESSAGE "Press a button."