BASIC-256 programs consist of a series of statements separated by newlines, which are executed in order.
Numeric constants are any numeric characters, preceded by an optional minus sign to indicate negative numbers, and an optional decimal followed by more numeric characters to indicate floating point values.
Positive integer values may also be expressed in binary (base 2), octal (base 8), and hexadecimal (base 16). Precede binary values with 0b (0b1110 = 14), octal with 0o (0o177 = 127), and hexadecimal with 0x (0xff = 255).
String constants are zero or more characters enclosed by double quotation marks(”).
Variables that hold numeric values must begin with a letter, and may consist of any number of alpha-numeric characters. They are case sensitive. They may be used interchangeably with numeric constants.
Variables that hold string values follow the same rules as numeric variables, but must end with a dollar sign ($). They may be used interchangeably with string constants.
Arrays are allocated using the DIM command or resided using Redim. They may hold numeric or string data. Access to specific elements in an array is accomplished by using square brackets along with the integer offset of the element, starting from zero. Arrays may also be dimensioned and accessed using two dimensions.
Array sizes may also be extracted using [?] [?,] and [,?] on the end of the array variable.
print myarray[4]
will display on the screen the fifth element in 'myarray'
An anonymous array is a set of numeric values or a set of string values, separated by commas, and enclosed in braces {}. An anonymous array can be used in place of an array variable, or it can be used to assign to an array variable.
dim myarray(4) myarray = {1, 2, 3, 4}
The operators +, -, *, /, and ^ are used to perform addition, subtraction, multiplication, division, exponentiation of floating point and integer numbers. Valid operands are numeric constants and/or numeric variables.
The operators %, \, &, |, and ~ are used to calculate modulo, integer division, bitwise and, bitwise or, and bitwise negation (not) of integer expressions. Floating point numbers will be coverted to an integer value before calculation.
The = operator is used both for assignment to variables, and to test for equality. The + operator may be used to perform concatenation of any combination of string constants and string variables. The : operator can separate multiple statements on a single line. The ; operator suppresses the new line that is printed from a PRINT statement. The # operator is a shortcut for the Rem statement, and is interchangeable with it.
Order of Operations | ||
---|---|---|
Level | Operators | Category/Description |
1 | ( ) | Grouping |
2 | ^ | Exponent |
3 | - ~ | Unary Minus and Bitwise Negation (NOT) |
4 | * / \ | Multiplication and Division |
5 | % | Integer Remainder (Mod) |
6 | + - | Addition, Concatenation, and Subtraction |
7 | & | | Bitwise And and Bitwise Or |
8 | < ⇐ > >= = <> | Comparison (Numeric and String) |
9 | NOT | Unary Not |
10 | AND | Logical And |
11 | OR | Logical Or |
12 | XOR | Logical Exclusive Or |
abs ( expression )
Returns the absolute value of a numeric expression.
print abs(-45) print abs(6.45)
will print
45 6.45
acos ( expression )
Computes the arc-cosine of expression. Angles are expressed in radians (0 to 2pi).
asc ( expression )
Converts the first character in a string expression to an integer representing it's ASCII value.
Asc | Chr | Asc | Chr | Asc | Chr | Asc | Chr | Asc | Chr | Asc | Chr |
---|---|---|---|---|---|---|---|---|---|---|---|
32 | SPACE | 48 | 0 | 64 | @ | 80 | P | 96 | ` | 112 | p |
33 | ! | 49 | 1 | 65 | A | 81 | Q | 97 | a | 113 | q |
34 | “ | 50 | 2 | 66 | B | 82 | R | 98 | b | 114 | r |
35 | # | 51 | 3 | 67 | C | 83 | S | 99 | c | 115 | s |
36 | $ | 52 | 4 | 68 | D | 84 | T | 100 | d | 116 | t |
37 | % | 53 | 5 | 69 | E | 85 | U | 101 | e | 117 | u |
38 | & | 54 | 6 | 70 | F | 86 | V | 102 | f | 118 | v |
39 | ' | 55 | 7 | 71 | G | 87 | W | 103 | g | 119 | w |
40 | ( | 56 | 8 | 72 | H | 88 | X | 104 | h | 120 | x |
41 | ) | 57 | 9 | 73 | I | 89 | Y | 105 | i | 121 | y |
42 | * | 58 | : | 74 | J | 90 | Z | 106 | j | 122 | z |
43 | + | 59 | ; | 75 | K | 91 | [ | 107 | k | 123 | { |
44 | , | 60 | < | 76 | L | 92 | \ | 108 | l | 124 | | |
45 | - | 61 | = | 77 | M | 93 | ] | 109 | m | 125 | } |
46 | . | 62 | > | 78 | N | 94 | ^ | 110 | n | 126 | ~ |
47 | / | 63 | ? | 79 | O | 95 | _ | 111 | o | 127 |
print asc("A") print asc("blue")
will print
65 98
0.9.4
asin ( expression )
Computes the arc-sine of expression. Angles are expressed in radians (0 to 2pi).
atan ( expression )
Computes the arc-tangent of expression. Angles are expressed in radians (0 to 2pi).
ceil ( expression )
Returns the lowest integer that is greater than or equal to expression.
print ceil(9.1) print ceil(-5.4)
will print
10 -5
changedir expression
changedir ( expression )
Change the current working directory to the path specified in expression. For all systems (including Windows) a forward slash (/) will be used to separate folders in a full path.
0.9.6r
chr ( expression )
Converts the integer expression into a single character string expression with the ASCII value of the number. See asc for a complete ASCII character conversion chart.
print chr(66)+chr(111)+chr(111)+chr(33)
will print
Boo!
0.9.4
circle x,y,r
Draws a circle centered at x,y with a radius r using the current color.
clickb
clickb ( )
Returns the buttons that the user last clicked on the mouse (if over the graphic output). Returns 0 if no click has been recorded. If multiple buttons have been pressed the value is the sum of the values for all pressed buttons.
Return Values | |
---|---|
Value | Mouse Button Pressed |
0 | None |
1 | Left |
2 | Right |
4 | Center |
# clear any prior mouse click clickclear # wait for the user to click the mouse print "click mouse on the graphics output" while clickb = 0 pause .01 endwhile # show where the user clicked print "The user clicked at (" + clickx + "," + clicky + ")"
0.9.4d
clickclear
clickclear ( )
Sets ClickB, Clickx, and Clicky to zero so that we can easily tell when the next mouse click is recorded.
See sample program on Clickb.
0.9.4d
clickx
clickx ( )
Returns the mouse x location of the mouse pointer over the graphic output last time the user clicked a mouse button.
See sample program on Clickb.
0.9.4d
clicky
clicky ( )
Returns the mouse y location of the mouse pointer over the graphic output last time the user clicked a mouse button.
See sample program on Clickb.
0.9.4d
close
close ( )
close filenumber
close ( filenumber )
Closes an open file. If no file is open to that file number, this command does nothing. If the file number is not specified file number zero (0) will be used.
color colorname
color ( colorname )
color red, blue, green
color ( red, blue, green )
color rgb_value
color ( rgb_value )
Sets the current drawing color to colorname; to RGB color made up of red, blue, green components; or to RGB value.
There is a special color named CLEAR, with a value of -1. If the current color is set to this value the pixels or shapes drawn will clear the pixels of the graphics output area and make them transparent. This is especially useful when creating sprites using the Spriteslice command.
Color names and RGB values | |||
---|---|---|---|
Color Name | RGB Values | ||
black | 0, 0, 0 | ||
white | 255, 255, 255 | ||
red | 255, 0, 0 | ||
darkred | 128, 0, 0 | ||
green | 0, 255, 0 | ||
darkgreen | 0, 128, 0 | ||
blue | 0, 0, 255 | ||
darkblue | 0, 0, 128 | ||
cyan | 0, 255, 255 | ||
darkcyan | 0, 128, 128 | ||
purple | 255, 0, 255 | ||
darkpurple | 128, 0, 128 | ||
yellow | 255, 255, 0 | ||
darkyellow | 128, 128 ,0 | ||
orange | 255, 102, 0 | ||
darkorange | 176, 61 ,0 | ||
grey | 164, 164 ,164 | ||
darkgrey | 128, 128 ,128 | ||
clear | -1 |
clg color rgb(128,128,128) rect 0,0,graphwidth, graphheight color red circle 100,100,50 color 255,160,160 circle 100,100,25
Will draw a grey rectangle with a red circle with a pink middle.
0.9.5m
cos ( expression )
Computes the cosine of expression. Expression must be in radians.
The cos function does not produce an exact result.
currentdir
currentdir ( )
Returns the fully qualified path name to BASIC-256's current directory. For all systems (including Windows) a forward slash (/) will be used to separate folders in a full path.
0.9.6r
day
day ( )
Returns the current system clock's day of the month (1-31).
print "today's date is "; print (month + 1) + "/" + day + "/" + year
will print|
today's date is 11/30/2009
0.9.4
dbclose
dbclose ( )
Close the currently open SQLite database file.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbcloseset
dbcloseset ( )
Close the currently open record set opened by DBOpenSet.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbexecute SqlStatement
dbexecute ( SqlStatement )
Execute an SQL statement on the open SQLite database file. This statement does not create a record set.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbfloat ( ColumnNumber )
Return a floating point (decimal value) from the specified column of the current row of the open recordset.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbint ( ColumnNumber )
Return an integer value from the specified column of the current row of the open recordset.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbopen SQLiteFile
dbopen ( SQLiteFile )
Open an SQLite database file. If the file does not exist then create it.
#database foo - create a database, populate a table, open a recordset and read data from table. # create a new database file or open it dbopen "dbtest.sqlite3" # delete old foo table - trap error if new database onerror errortrap dbexecute "drop table foo;" offerror # create and populate dbexecute "create table foo (id integer, words text, value decimal);" dbexecute "insert into foo values (1,'one',3.14);" dbexecute "insert into foo values (2,'two',6.28);" dbexecute "insert into foo values (3,'three',9.43);" # open a recordset and loop through the rows of data dbopenset "select * from foo order by words;" while dbrow() print dbint(0) + dbstring(1) + dbfloat(2) end while dbcloseset # wrap everything up dbclose end errortrap: # accept error - display nothing - return to next statement return
will display
1one3.14 3three9.43 2two6.28
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbopenset SqlStatement
dbopenset ( SqlStatement )
Perform an SQL statement and create a record set so that the program may loop through and use the results.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbrow
dbrow ( )
Function that advances the record set to the next row. Returns a true value if there is a row or false if we are at the end of the record set.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dbstring ( ColumnNumber )
Return a string from the specified column of the current row of the open recordset.
See example of usage on DBOpen page.
More information about databases in general and SQLite specifically can be found at SQLite Home Page and SQL at Wikipedia.
0.9.6y
dim numericvariable ( integer )
dim stringvariable$ ( integer )
dim numericvariable ( rows , columns )
dim stringvariable$ ( rows , columns )
Returns a newly created single dimensional array of length integer or a 2 dimensional array thst can be addressed by row and column. Depending on the variable assignment, a string or numerical array is created.
The first element of an array has an index of 0 (zero). Indexes range from 0 to length-1.
dim z(5) z = {1, 2, 3, 4, 5} print z[0] + " " + z[4]
will print
1 5
dim c$(4) c$ = {"cow", "brow", "how", "now"} print c$[2] + " " + c$[3] + " "; print c$[1] + " " + c$[0] + "?"
will print
how now brown cow?
end
Halts program execution.
print "I am done." end print "Or am I?"
will print
I am done.
eof
eof()
eof(filenumber)
Returns a binary flag (true/false) that will signal if we have read to the End Of File (EOF). If file number is not specified then file number zero (0) will be used.
0.9.4
exists ( expression )
Returns a binary flag (true/false) that will signal if the file path specified by the expression exists.
0.9.4
fastgraphics
Turns fastgraphics mode on, until the program is halted. Fastgraphics mode means that the graphics display is not updated until a REFRESH command is issued. It can be used to significantly speed up complex animations and eliminate flicker.
When doing animation, it's recommended to do all of your drawing commands in subroutines and use a single REFRESH command after all drawing has been done for that frame.
float ( expression )
Convert expression to a floating point (decimal) number. Float will convert a string or an integer to a decimal value. If the expression can not be converted then a zero will be returned.
0.9.4
floor ( expression )
Returns the greatest integer that is less than or equal to expression
font fontname, point, weight
Sets the font used by the text command to fontname. Size is defined in points (1/72”) Weight represents a number from 1 to 100 that defines how dark the letters will be drawn. Light=25, Normal=50, and Bold=75.
color grey rect 0,0,graphwidth,graphheight color red font "Times New Roman",18,50 text 10,100,"This is Times New Roman" color darkgreen font "Tahoma",28,100 text 10,200,"This is BOLD!"
0.9.4
getcolor
getcolor()
Returns the RGB value of the current drawing color (last set by color statement). RGB is calculated by taking ((red * 256) + green * 256) + blue where red, green, and blue are between 0 and 255. If the drawing color has been set to CLEAR a -1 will be returned.
color red print getcolor
will print
16711680
0.9.5m
getslice(x, y, width, height)
Return a string that contains a Hexadecimal representation of the rectangle defined by the parameters. String is formatted as first 4 bytes - width, next 4 bytes - height, 6 bytes for each pixel (width * height).
0.9.6b
goto label
Jumps to the specified label.
print "I"; goto skipit print " don't"; skipit: # print " want cookies."
will print
I want cookies.
graphheight
graphheight()
Returns the height (y dimension) of the current graphics display window.
0.9.3
graphsize x_expression, y_expression
Changes the size of the graphics display window and redraws the BASIC256 application.
0.9.3
graphwidth
graphwidth()
Returns the width (x dimension) of the current graphics display window.
0.9.3
hour
hour()
Returns the current system clock's hour of the day (0-23).
# display nice date dim months$(12) months$ = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} print year + "-" + months$[month] + "-" + right("0" + day, 2) # display pretty time h = hour if h > 12 then h = h - 12 ampm$ = "PM" else ampm$ = "AM" end if if h = 0 then h = 12 print right("0" + h, 2) + "-" + right("0" + minute, 2) + "-" + right("0" + second, 2) + " " + ampm$
Will print something like.
2010-July-15 10-00-02 PM
0.9.4
instr( string1, string2 )
Check to see if string2 is contained in string1. If it is, then this function will return the index of starting character of the first place where string2 occurs. Otherwise, this function will return 0.
String indices begin at 1.
print instr("Hello", "lo")
will display
4
int ( expression )
Convert expression to an integer (whole) number. Int will convert a string or a float to an integer value. If the expression can not be converted then a zero will be returned.
imgload x, y, filename
imgload x, y, scale, filename
imgload x, y, scale, rotation, filename
Load an image or picture from a file and paint it on the Graphics Output Window.
The parameters x and y represent the location on the screen for the CENTER of the loaded image. This behaviour is different than all of the other graphics statements. The axis of rotation will also be this CENTER point.\\The Imgload starement will read in most common image file formats including: BMP (Windows Bitmap), GIF (Graphic Interchange Format),JPG/JPEG (Joint Photographic Experts Group), and PNG (Portable Network Graphics).
Optionally scales size of the loaded image by the defined scale (1=normal size). Also optionally rotates the image by a specified angle around the images center (clockwise in radians).
0.9.6l
input expression, stringvariable
input expression, numericvariable
input stringvariable
input numericvarvariable
Waits for the user to type a line of text into the text output window. When the user hits the enter or return key, the line is read in to stringvar or numericvariable.
User may optionally be prompted for the input by expression.
If a numeric variable is specified and non-numeric data is entered a zero will be assigned to the numeric variable.
References to array elements may also be specified.
key
key()
Immediately returns an integer value corresponding to the currently pressed keyboard key. If no key has been pressed since the last call to the key function then the number zero (0) will be returned.
if key = 47 then print key
will not display the desired results, because it's calling key twice in succession, and will return different values each time. This code will do what you want:
a = key if a = 47 then print a
lasterror
lasterror ( )
Returns the last runtime error number.
See example of usage on Error Codes page.
0.9.6z
lasterrorextra
lasterrorextra ( )
Returns statement specific “extra” information about the error.
See example of usage on Error Codes page.
0.9.6z
lasterrorline
lasterrorline ( )
Returns the line number in the program where the runtime error happened.
See example of usage on Error Codes page.
0.9.6z
lasterrormessage
lasterrormessage ( )
Returns a string representing the last runtime error.
See example of usage on Error Codes page.
0.9.6z
left( string, length)
Returns a portion of the specified string, starting from the first character on the left and continuing for length characters.
print left("Hello", 2)
will display
He
0.9.5b
line x0, y0, x1, y1
line(x0, y0, x1, y1)
Draws a line from the point x0,y0 to the point x1, y1.
log ( expression )
Return the base e lograthim of expression.
0.9.5w
lower( string)
Returns string with all alphabetic characters converted to lower case.
0.9.5e
mid( string, start character, length)
Returns a portion of the specified string, starting from the start character, and continuing for length characters.
print mid("Hello", 2, 3)
will display
ell
minute
minute()
Returns the current system clock's minute of the hour (0-59).
# display nice date dim months$(12) months$ = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} print year + "-" + months$[month] + "-" + right("0" + day, 2) # display pretty time h = hour if h > 12 then h = h - 12 ampm$ = "PM" else ampm$ = "AM" end if if h = 0 then h = 12 print right("0" + h, 2) + "-" + right("0" + minute, 2) + "-" + right("0" + second, 2) + " " + ampm$
Will print something like.
2010-July-15 10-00-02 PM
0.9.4
month
month()
Returns the current system clock's month. January is 0, February is 1… December is 11.
cls dim n$(12) n$ = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} print day + "-" + n$[month] + "-" + year
on New Years will display
1-Jan-2010
0.9.4
mouseb
mouseb()
Returns the buttons that currently pressed on the mouse (if over the graphic output). Returns 0 if no click has been recorded. If multiple buttons have been pressed the value is the sum of the values for all pressed buttons.
Return Values | |
---|---|
Value | Mouse Button Pressed |
0 | None |
1 | Left |
2 | Right |
4 | Center |
0.9.4d
mousex
mousex()
Returns the current or last mouse x location of the mouse pointer over the graphic output.
0.9.4d
mousey
mousey()
Returns the current or last mouse y location of the mouse pointer over the graphic output.
0.9.4d
netclose
netclose ( )
netclose socket_number
netclose ( socket_number )
Close the specified network connection (socket). If socket_number is not specified socket number zero (0) will be used.
See example of usage on NetConnect page.
0.9.6.31
netconnect server_name, port_number
netconnect ( server_name, port_number )
netconnect socket_number, server_name, port_number
netconnect ( socket_number, server_name, port_number )
Open a network connection (client) to a server. The IP address or host name of a server are specified in the server_name argument, and the specific network port number in the port_number argument. If socket_number is not specified socket number zero (0) will be used.
Open two instances of BASIC-256 on a single computer. Paste the “server” code into one and the “client” code into the other. Run the server first and the client second. You can see how the messages are sent back and forth between the two different processes.
# get a message and send back success print "wait for connection on " + netaddress() netlisten 9997 print "got connection" do while not netdata pause .1 print "."; end while n$ = netread print n$ netwrite "I got '" + n$ + "'." until n$ = "end" netclose
will display (where xxx.xxx.xxx.xxx is the IPv4 address of your computer)
wait for connection on xxx.xxx.xxx.xxx got connection .1 Hi There ....2 Hi There ........3 Hi There ..........4 Hi There .....5 Hi There .......6 Hi There ....7 Hi There ..........8 Hi There ....9 Hi There .....10 Hi There .end
# have the user enter a message and send it to the server input "enter message?", m$ netconnect "127.0.0.1", 9997 for t = 1 to 10 pause rand netwrite t + " " + m$ print netread next t netwrite "end" print netread netclose
will display
enter message?Hi There I got '1 Hi There'. I got '2 Hi There'. I got '3 Hi There'. I got '4 Hi There'. I got '5 Hi There'. I got '6 Hi There'. I got '7 Hi There'. I got '8 Hi There'. I got '9 Hi There'. I got '10 Hi There'. I got 'end'.
0.9.6.31
netdata
netdata ( )
netdata socket_number
netdata ( socket_number )
Returns a true value (1) of there is data waiting to be read in using the NetRead function, else returns false (0). If socket_number is not specified socket number zero (0) will be used.
See example of usage on NetConnect page.
0.9.6.31
netlisten port_number
netlisten ( port_number)
netlisten socket_number, port_number
netlisten ( socket_number, port_number)
Open up a network connection (server) on a specific port address and wait for another program to connect. If socket_number is not specified socket number zero (0) will be used.
See example of usage on NetConnect page.
0.9.6.31
netread
netread ( )
netread ( socket_number )
Read data from the specified network connection and return it as a string. This function will wait until data is received. If socket_number is not specified socket number zero (0) will be used.
See example of usage on NetConnect page.
0.9.6.31
netwrite string
netwrite ( string )
netwrite socket_number, string
netwrite ( socket_number, string )
Send a string to the specified open network connection. If socket_number is not specified socket number zero (0) will be used.
See example of usage on NetConnect page.
0.9.6.31
open filename
open(filename)
open filenumber, filename
open(filenumber, filename)
Opens a file for reading and writing. The filename is specified as a string, and may be an absolute or relative path. If the file number is not specified file number zero (0) will be used.
BASIC256 may have up to 8 files open at a single time. The files are numbered from 0 to 7. Opening a file to a number while another is already open to that number will close the open file.
offerror
Turns off error trapping and restores the default error behavior.
See example of usage on Error Codes page.
0.9.6z
onerror label
Causes the subroutine at label to be executed when an runtime error occurs. Program control may be resumed at the next statement with a Return statement in the subroutine.
See example of usage on Error Codes page.
0.9.6z
pause seconds
pause (seconds)
Halts execution for the specified number of seconds. The seconds value may be a decimal value, so sub-second precision is possible.
pixel (x, y )
Returns the RGB value of the pixel at the x and y coordinate. If the pixels has not been set since the last Clg command or was drawn with the color CLEAR a -1 will be returned.
0.9.5m
plot x, y
plot ( x, y )
Changes the pixel located at x,y in the graphics output window to the current color.
poly numeric array variable
poly {x1, y1, x2, y2, x3, y3 …}
Draws a polygon. The sides of the polygon are defined by the values stored in the array, which should be stored as x,y pairs, sequentially. The length of the array/2 will define the number of points. A polygon may also be specified using a list of x,y pairs enclosed in curly braces {}.
The number of points in the array argument was removed from the poly statement in version 0.9.4.
print expression [ ; ]
Writes text to the text output window, appending a new line. If the optional semicolon is included, no new line is appended.
putslice x, y, slice$
putslice x, y, slice$, transparent color
Put the graphics stored in the slice string on the screen at x,y. If a transparent color is specified then do not plot points of that color in the slice.
0.9.6b
rand
rand()
Returns a random number between 0 and 1. The distribution of the values is uniform.
To produce random numbers between other values, simple multiply or add the appropriate numbers. For example, to generate an integer between 0 and 10, use int(rand * 10).
read
read()
read(filenumber)
Reads and returns a token from an open file. A token is any string of characters that is separated by a space, tab, or newline character. If the file number is not specified file number zero (0) will be used.
readline
readline()
readline(filenumber)
Reads and returns an entire line from an open file. If the file number is not specified file number zero (0) will be used.
rect x,y,width,height
rect ( x, y, width, height )
Draws a width x height pixel rectangle using the current color. The top left corner is located at x,y.
redim numericvariable( integer )
redim stringvariable$( integer )
redim numericvariable( rows , columns )
redim stringvariable$( rows , columns )
Re-sizes a previously created array, preserving data. If an array is enlarged then the new elements will be initialized with zero or the empty string. If an array is reduced in size the elements trimmed from the end are lost.
0.9.5t
refresh
Updates the graphics output window to show all drawing since the previous refresh command. Refresh only works in Fastgraphics mode
rem comment
# comment
Line comment. A line beginning with REM (or the shortened #) is ignored.
reset
reset()
reset(filenumber)
Clears an open file. All data stored in the file is lost. If the file number is not specified file number zero (0) will be used.
rgb(red, green, blue )
Returns the RGB value of the color made up of the red, green, and blue components. Legal values for red, greem, and blue are 0 to 255.
0.9.5m
right( string, length)
Returns a portion of the specified string, starting from the last length characters from the right end of the of the string.
print right("Hello", 2)
will display
lo
0.9.5b
say expression say ( expression )
Uses the the system Text to Speech (TTS) engine to say the expression. In LINUX the FLite or eSpeak libraries are required. In Windows the current default SAPI voice will be used.
0.9.4
second
second()
Returns the current system clock's second of the current minute (0-59).
# display nice date dim months$(12) months$ = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} print year + "-" + months$[month] + "-" + right("0" + day, 2) # display pretty time h = hour if h > 12 then h = h - 12 ampm$ = "PM" else ampm$ = "AM" end if if h = 0 then h = 12 print right("0" + h, 2) + "-" + right("0" + minute, 2) + "-" + right("0" + second, 2) + " " + ampm$
Will print something like.
2010-July-15 10-00-02 PM
0.9.4
seek location
seek ( location )
seek filenumber, location
seek ( filenumber, location )
Moves the read/write location to a specific location (offset in bytes from the start of the file) within an open file. If the file number is not specified file number zero (0) will be used.
0.9.4
sin ( expression )
Computes the sine of expression. Expression must be in radians.
The sin function does not produce an exact result.
size
size()
size(filenumber)
Returns the length, in bytes, of an opened file. If the file number is not specified file number zero (0) will be used.
0.9.4
sound frequency, duration
sound ( frequency, duration )
sound ( array )
sound array
sound {frequency1, duration1, frequency2, duration2, …}
Play a sound from the computer's speakers.Frequency is expressed in Hz and duration is expressed in milliseconds (1000 in a second). An array or list containing frequency and durations may also be passed. This eliminates any clicking between sounds when more than one is being output sequentially. Sound support for LINUX systems was added in version 0.9.5g. Sound was changed to use the default sound device in Windows in version 0.9.5h
spritecollide ( sprite1, sprite2)
Function returns true if the two sprites are colliding. The Spritecollide function assumes that the sprites are bounded by a rectangle the size of the loaded image. Collision is calculated by using these rectangles. For round or oddly shaped sprites this function may over detect collision.
Spritedim, Spriteh, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spritedim n
spritedim ( n )
Create n sprite placeholders in memory. Sprites are accessed in your program by a sprite number from 0 to n-1.
Spritecollide, Spriteh, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spriteh ( spritenumber )
Returns the height, in pixels, of a loaded sprite.
Spritecollide, Spritedim, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spritehide spritenumber spritehide ( spritenumber )
Hides a sprite. All image and position information is retained.
Spritecollide, Spritedim, Spriteh, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spriteload spritenumber, filename
spriteload ( spritenumber, filename )
Load an image or picture from a file and save it as a sprite. The sprite will be active and movable but will not display on the screen until the Spriteshow statement is executed for that sprite.\\The Spriteload statement will read in most common image file formats including: BMP (Windows Bitmap), GIF (Graphic Interchange Format),JPG/JPEG (Joint Photographic Experts Group), and PNG (Portable Network Graphics).
Spritecollide, Spritedim, Spriteh, Spritehide, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spritemove spritenumber, dx, dy
spritemove ( spritenumber, dx, dy )
Move a sprite from its current position by the specified number of pixels. Motion will be limited to the current screen.
Spritecollide, Spritedim, Spriteh, Spritehide, Spriteload, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spriteplace spritenumber, x, y
spriteplace ( spritenumber, x, y )
Place the center of a sprite at a specific location on the screen. Like Imgload sprite positioning is relative to the center of the sprite and not the top left corner as with most other graphical statements.
Spritecollide, Spritedim, Spriteh, Spritehide, Spriteload, Spritemove, Spriteshow, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spriteshow spritenumber
spriteshow ( spritenumber )
Show a hidden sprite.
Spritecollide, Spritedim, Spriteh, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteslice, Spritev, Spritew, Spritex, Spritey
0.9.6n
spriteslice spritenumber, x, y, width, height
spriteslice ( spritenumber, x, y, width, height )
Copy the rectangular region of the screen with it's top left corner represented by x and y of the specified height and width and create a sprite. The sprite will be active and movable but will not be visible until the Spriteshow statement is executed. It is recommended that you execute the Clg command before drawing and slicing the sprite. All unpainted pixels will be transparent when the sprite is drawn on the screen. Transparent pixels may also be set by drawing with the color CLEAR.
Spritecollide, Spritedim, Spriteh, Spritehide, Spritemove, Spriteplace, Spriteshow, Spritev, Spritew, Spritex, Spritey
0.9.6o
spritev ( spritenumber )
Returns true if the sprite is visible.
Spritecollide, Spritedim, Spriteh, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritex, Spritey
0.9.6o
spritew ( spritenumber )
Returns the width, in pixels, of a loaded sprite.
Spritecollide, Spritedim, Spriteh, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritex, Spritey
0.9.6n
spritex ( spritenumber )
Returns the x coordinate of the center of a loaded sprite.
Spritecollide, Spritedim, Spriteh, Spritehide, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritey
0.9.6n
spritey ( spritenumber )
Returns the y coordinate of the center of a loaded sprite.
Spritecollide, Spritedim, Spriteh, Spriteload, Spritemove, Spriteplace, Spriteshow, Spriteslice, Spritev, Spritew, Spritex
0.9.6n
stamp x, y, array
stamp x, y, {x1, y1, x2, y2, x3, y3 …}
stamp x, y, scale, array
stamp x, y, scale, {x1, y1, x2, y2, x3, y3 …}
stamp x, y, scale, rotation, array
stamp x, y, scale, rotation, {x1, y1, x2, y2, x3, y3 …}
Draws a polygon with top left corner (origin) at x, y. Optionally scales size of polygon by the defined scale (1=normal size). Also optionally rotates the polygon by a specified angle around the origin (clockwise in radians). The sides of the polygon are defined by the values in an array, which should be stored as x,y pairs, sequentially. The length of the array/2 will define the number of points. A stamped polygon can also be specified using a list of x,y pairs enclosed in curly braces {}.
Both of the code blocks below will draw a pair of green triangles on the graphics window:
clg color blue rect 0,0,300,300 color green dim tri(6) tri = {0, 0, 100, 100, 0, 100} # stamp the triangle at 0,0 (full size) stamp 100, 100, tri # stamp the triangle at 200,100 (half size) stamp 200, 100, .5, tri
clg color blue rect 0,0,300,300 color green # stamp the triangle at 0,0 (full size) stamp 100, 100, {0, 0, 100, 100, 0, 100} # stamp the triangle at 200,100 (half size) stamp 200, 100, .5, {0, 0, 100, 100, 0, 100}
0.9.4
string ( expression )
Returns the string representation of a number.
system expression
system ( expression )
Execute a system command in a terminal window. WARNING: This can be a very dangerous statement. Only use it if you know what you are doing.
This statement may be disabled because of potential system security issues. Availability may be configured in the IDE by going to the Edit>Preferences menu.
0.9.5h
tan ( expression )
Computes the tangent of expression. Expression must be in radians.
The tan function does not produce an exact result.
text x, y, string
text ( x, y, string )
Paints a text string on the Graphics Output Window at x, y using the current color and font.
color grey rect 0,0,graphwidth,graphheight color red font "Times New Roman",18,50 text 10,100,"This is Times New Roman" color darkgreen font "Tahoma",28,100 text 10,200,"This is BOLD!"
0.9.4
upper ( string )
Returns string with all alphabetic characters converted to upper case.
print upper("BlUe!")
will display
BLUE!
0.9.5e
volume level
volume ( level )
Adjust the volume of the notes played with the Sound command. Volume levels must be numeric values from 0 to 10. The default volume is 5.
0.9.5i
wavplay filename
wavplay ( filename )
Play WAV audio file asynchronously (in the background).
0.9.4
wavstop
Stop playing the current asynchronous (background) WAV audio file.
0.9.4
write string
write ( string )
write filenumber, string
write ( filenumber, string )
Writes string to the end of an open file. If the file number is not specified file number zero (0) will be used.
writeline string
writeline ( string )
writeline filenumber, string
writeline ( filenumber, string )
Writes string append with a newline character to the end of an open file. If the file number is not specified file number zero (0) will be used.
0.9.4
year
year ( )
Returns the current system clock's 4 digit year.
print "today's date is "; print (month + 1) + "/" + day + "/" + year
will display
today's date is 11/30/2009
0.9.4