![]() |
---|
>KEYWORDS The following keywords are reserved with built in functionality and should not be used as variable names. IF THEN END MARKER BLOCK RETURN WHILE DO TRUE FALSE LIST NUM ASK INDEX VAL LEN PRINT GOTO ADD REMOVE |
---|
>IF STATEMENTS There are two forms of if statements in Route. Single-line if statements and multi-line 'block' if-then statements. |
---|
SINGLE-LINE IF STATEMENT EXAMPLE fruit = "apple" IF fruit == "apple" PRINT "Fruit does equal apple!" PRINT "This prints regardless of fruits value." MULTI-LINE IF STATEMENT EXAMPLE fruit = "apple" IF fruit == "apple" THEN PRINT "Fruit does equal apple!" PRINT "This only prints if fruit equals apple!" END PRINT "This prints regardless of fruits value." |
---|
>USER INPUT The ASK command is used to take a line of user input from the console. It takes one parameter, a string that will be printed to the console. |
---|
ASK EXAMPLE name = ASK "Enter your name: " PRINT "Welcome to Route, " PRINT name |
---|
>MATH OPERATORS Math operations are written in the form "variable sign= parameter" where the parameter will be applied to the variable using the sign. |
---|
MATH EXAMPLE number = 10 number += 1 PRINT number number -= 1 PRINT number number *= 2 PRINT number number /= 2 PRINT number |
---|
>STRING CONCATENATION String concatenation reuses the += operator and combines two strings into one. |
---|
CONCATENATION EXAMPLE string = "MIKE" string2 = "JON" string += " AND " string += string2 PRINT string |
---|
>CASTING A STRING TO A NUMBER Strings can be casted to numbers using the NUM command, which takes one parameter that will be casted to an integer or float appropriately. |
---|
NUM EXAMPLE stringNumber = ASK "Enter any number: " number = NUM stringNumber |
---|