Cahfee V. 2.0
comment
No code is run on this line. Must be at the beginning of a line.Good for explaining code.
Write
//before your comment:
//the best program ever.
//made by Andrew.
clear screen
Clears out the screen.Use
cls
cls
delay
Waits an amount of time in milliseconds.delay 5000This code will wait 5 seconds.
pause
Waits for the user to press space.pause
This code will print:
Press space to continue...The program will stop until the user presses space.
goto - line bookmarks
Name a line with:[linename]
Redirect the program back to that line with
goto [linename]
:loop
echo Hey!
goto loop
This will print "Hey!" over and over.
echo
Print a line of text.echo hello world!
This prints:
hello world!
variables
Define a variable withvar
Syntax:
var [varname]
var [varname]=[varcontent]
To call a variable, use the syntax
$[variablename]$
Example:
var myname=Andrew
echo $myname$The above will set a variable "myname" to "Andrew" and then print:
Andrew
user input
Asks the user a question and stores the answer in a variable.u [variablename]
u [variablename]=[question]
If a question is not specified, it will just ask the variable name as the question.
u myguess=What's your guess?
The above will ask "What's your guess?" and store the user's answer in a variable "myguess."
math
Set a variable to a mathematical output withm
Syntax:
m [varname]=[number][operator][number]where "operator" is +, -, *, or /
Example:
var mynumA=10
m mynumB=$mynumA$+5
echo $mynumA$ + 5 = $mynumB$The above will set "mynumA" to 10, "mynumB" to 15, and then print:
10 + 5 = 15
round
Round a number into a variable.Syntax:
round [varname]=[number]
Example:
var mynumA=10.5
round myroundnum=$mynumA$
round myroundnumB=15.3The above will set "myroundnum" to 11 and "myroundnumB" to 15.
IF
Check if a condition is true.Syntax:
if [item][compare][item]where "compare" is =, >, <, or !
and "item" is a string, number, or variable.
Must have an
endifto show where to skip to if condition is false.
Example:
:retry
u password=What's your password?
if $password$=andrew
echo That's right!
goto loggedin
endif
if $password$!andrew
echo That's wrong.
goto retry
endif
:loggedin
echo You're logged in!
The above will ask the user for a password and only log in when it's correct ("andrew").