Les programmes sous BASIC-256 sont formés d'une série d'instructions séparées par un retour à la ligne et qui sont exécutées dans l'ordre.
Les constantes numériques peuvent être n'importe quel(s) caractère(s) numérique(s), précédé ou non d'un signe moins (pour les nombres négatifs) et une éventuelle décimale (pour les nombres à virgule flottante).
Les nombres positifs entiers peuvent aussi être exprimées en binaire (base 2), octal (base 8) et hexadécimal (base 16). Faites précéder les entrées binaires de 0b (0b1110 = 14), octales de 0o (0o177 = 127) et hexadécimales de 0x (0xff = 255).
Les (constantes) chaînes de caractères sont composées de zéro ou plus de caractères entourés de guillemets (”).
Le nom des variables contenant des valeurs numériques doit commencer par une lettre et peut comporter n'importe quel nombre de caractères alpha-numériques. Il est sensible à la casse (on différencie majuscule et minuscule). Il peut être utilisé en alternance de constantes numériques (i.e. on peut passer de l'un à l'autre, les deux se valent).
Le nom des variables contenant des chaînes de caractères suit les mêmes règles que celui des variables numériques, mais doit finir par un symbole dollar ($). Il peut, lui aussi, être utilisé en alternance de constantes.
Les tableaux sot affectés à l'aide de la commande DIM ou redimensionnés avec Redim. Ils peuvent contenir des données numériques ou des chaînes de caractères. Pour accéder à un élément donné d'un tableau on utilise les crochets ”[ et ]” autour du rang de l'élément voulu (la numérotation partant de zéro). Les tableaux peuvent aussi dimensionnés et interrogés sur 2 dimensions.
Le taille d'un tableau peut être retournée par une des commandes suivantes : [?] [?,] ou [,?] à la fin du nom du tableau.
print myarray[4]
affichera à l'écran le 5eme élément du tableau 'myarray'
Un tableau anonyme est une série de valeurs numériques ou de chaînes de caractères, séparées par des virgules, et encadrées par des accolades {}. Un tableau anonyme peut ête utilisé à la place d'une variable d'un tableau ou pour assigner une variable d'un tableau.
dim myarray(4) myarray = {1, 2, 3, 4}
PS : je ne suis pas sûr de la traduction de cette page. C'est ainsi que je l'ai compris, mais sans certitude.
Les opérateurs +, -, *, /, ^, %, et sont utilisés pour réaliser respectivement une addition, une soustraction, une multiplication, une division, une puissance, un modulo et une division arrondie à l'entier des opérandes. Les opérandes valides sont des constantes numériques et/ou des varaibles numériques.
L'opérateur = est utilisé à la fois pour assigner une valeur à une varaiable et pour tester l'égalité. L'opérateur + peut être utilisé pour réaliser la concaténation (= mise bout à bout) de n'importe quelle combinaison de chaînes de constantes et de variables.string variables. L'opératuer : peut servir à séparer plusieurs instructions sur une même ligne. L'opérateur ; supprime le retour à la ligne qu'introduirait une commande PRINT. L'opérateur # est un raccourci de la commande Rem et interchangeable avec celle-ci.
Ordre des opérations | ||
---|---|---|
Niveau | Opérateur | Catégorie/Description |
1 | ( ) | Groupement |
2 | ^ | Exposant |
3 | - | Moins |
4 | * / \ | Multiplication et Division |
5 | % | Reste entier (Mod) |
6 | + - | Addition, Concaténation et Soustraction |
7 | < ⇐ > >= = <> | Comparaison (Numérique et Chaîne) |
8 | NOT | “Non” logique |
9 | AND | “Et” logique |
10 | OR | “Ou” logique |
11 | XOR | “Ou exclusif” logique |
abs ( expression )
Retourne la valeur absolue d'une expression numérique.
print abs(-45) print abs(6.45)
permet d'afficher
45 6.45
acos ( expression )
Calcule l'arc-cosinus d'expression. Les angles sont exprimés en radians (0 à 2 pi).
asc ( expression )
Convertit le premier caractère d'une chaîne en sa valeur ASCII (= un nombre entier).
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("bleu")
permet d'afficher
65 98
0.9.4
asin ( expression )
Calcule l'arc-sinus d'une expression. Les angles sont exprimés en (0 à 2pi).
atan ( expression )
Calcule l'arc-tangente d'une expression. Les angles sont exprimés en radians (0 à 2pi).
ceil ( expression )
REtourne l'entier immédiatement inférieur ou égal à une expression.
print ceil(9.1) print ceil(-5.4)
fera afficher
10 -5
changedir expression
changedir ( expression )
Change de répertoire de travail pour le chemin spécifié par l'expression. Pour toutes le OS (y compris Windows) un anti-slash (/) est utilisé pour séparer les répertoire au sein d'un chemin complet.
0.9.6r
chr ( expression )
Converti l'entier expression en le caractère correspondant en code ASCII. Voir la page consacrée à asc pour un tableau de converson des caractères ASCII.
print chr(66)+chr(111)+chr(111)+chr(33)
affichera
Boo!
0.9.4
circle x,y,r
Trace un cercle dont les coordonnées du centre sont x,y et le rayon r. Le cercle étant de la couleur active.
clickb
clickb ( )
Retourne quel(s) bouton(s) de la souris l'utilisateur a pressé (quand il est sur la partie graphic output). Retourne 0 si aucun clic n'a été détecté. Si plusieurs boutons ont été pressés la valeur est la somme des valeurs des boutons pressés.
Valeurs retournées | |
---|---|
Valeur | Bouton pressé |
0 | aucun |
1 | gauche |
2 | droit |
4 | du centre |
# réinitialise le compte des clics clickclear # attend que l'utilisateur clique print "cliquez avec la souris sur la surface graphics output" while clickb = 0 pause .01 endwhile # Montre où l'utilisatur a cliqué print "L'utilisateur a cliqué le point de coordonnées (" + clickx + "," + clicky + ")"
0.9.4d
clickclear
clickclear ( )
Remet ClickB, Clickx et Clicky à zéro afin de pouvoir détecter facilement un clic de la souris.
Voir le programme de la page de Clickb.
0.9.4d
clickx
clickx ( )
Retourne l'abscisse x du pointeur de la souris sur la surface graphic output au dernier clic.
Voir le programme de la page de Clickb.
0.9.4d
clicky
clicky ( )
Retourne l'ordonnée y du pointeur de la souris sur la surface graphic output au dernier clic.
Voir le programme sur la page de Clickb.
0.9.4d
clg
Clears the graphics output window.
close
close ( )
close filenumber
close ( filenumber )
Ferme un fichier ouvert. Di aucun fichier n'est ouvert à ce numéro, la commande n'a aucun effet. Si aucun numéro de fichier n'est spécifié, le numéro de fichier utilisé sera le zéro.
cls
Nettoie la fenêtre text output.
color colorname
color ( colorname )
color red, blue, green
color ( red, blue, green )
color rgb_value
color ( rgb_value )
Règle la couleur active comme étant la couleur appelée colorname; de composantes rouge, bleue et verte red, blue, green ; ou de valeur RGB rgb_value.
Il y a une couleur spéciale appelée CLEAR, de valeur -1. Si la couleur courante est réglée sur cette valeur, les pixels ou formes dessinés effaceront les pixels sur lesquels ils passeront et les rendront transparents. C'est particulièrement utile pour créer des sprites avec la commande Spriteslice.
Noms des couleurs et leur valeur RGB | |||
---|---|---|---|
Nom de la couleur | Valeur RGB | ||
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
Dessinera un rectangle gris avec dedans un cercle rouge et un centre rose.
0.9.5m
cos ( expression )
Calcule le cosinus de l'expression. L'expression doit être exprimé en radians.
La fonction cos ne retourne pas un résultat exact (mais une valur approchée).
clg color black # Trace une ligne à travers la fenêtre graphic output line 0,150,300,150 # point de départ lastx = 0 lasty = cos(0) * 50 + 150 # puis pas après pas trace la courbe du cosinus for x = 0 to 300 step 5 angle = x / 300 * 2 * pi y = cos(angle) * 50 + 150 line lastx, lasty, x, y lastx = x lasty = y next x
currentdir
currentdir ( )
Retourne le chemin complet du répertoire courant. Pour toutes les OS (y compris Windows) un anti-slash (/) sépare les répertoires du chemin.
0.9.6r
day
day()
Renvoie le jour du mois actuel (1-31) d'après l'horloge système.
print "Aujourd'hui nous sommes le "; print day() + "/" + (month() + 1) + "/" + year()
affichera par exemple :
Aujourd'hui nous sommes le 1/5/2013
0.9.4
dbclose
dbclose ( )
Ferme le fichier de données SQLite actuellement ouvert.
Voir l'exemple de la page de DBOpen.
De plus amples informations (en anglais) sur les bases de données en général et SQLite en particulier sont disponibles aux adresses suivantes : SQLite Home Page et 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 )
Exécute une commande SQL sur le fichier de base de données SQLite ouvert. Cette commande ne produit pas d'enregistrement.
Voir l'exemple de la page de DBOpen.
De plus amples informations (en anglais) sur les bases de données en général et SQLite en particulier sont disponibles aux adresses suivantes : Page d'accueil de SQLite et SQL sur Wikipedia.
0.9.6y
dbfloat ( ColumnNumber )
Retounrne une valeur décimale (virgule flottante) de la colonne demandée de la ligne active de l'enregistrement ouvert.
Voir l'exemple de la page de DBOpen.
De plus amples informations (en anglais) sur les bases de données en général et SQLite en particulier, sont disponibles aux adresses suivantes : Page d'accueil de SQLite et SQL sur Wikipedia.
0.9.6y
dbint ( ColumnNumber )
Retourne la valeur entière de la colonne demandée de la ligne active de l'enregistrement ouvert.
Voir l'exemple de la page de DBOpen.
De plus amples informations (en anglais) sur les bases de données en général et SQLite en particulier, sont disponibles aux adresses suivantes : Page d'accueil de SQLite et SQL sur Wikipedia.
0.9.6y
dbopen SQLiteFile
dbopen ( SQLiteFile )
Ouvre un fichier de base de données SQLite. Si le fichier n'existe pas, il est créé.
#database foo - crée une base de données, peuple une table, ouvre un enregistrement et lit les données de la table. # crée un nouveau fichier de base de données ou l'ouvre dbopen "dbtest.sqlite3" # efface l'ancienne foo table - renvoie une erreur si c'est une nouvelle base de données onerror errortrap dbexecute "drop table foo;" offerror # crée et peuple 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);" # ouvre un enregistrement et tourne en boucle à travers les lignes de données dbopenset "select * from foo order by words;" while dbrow() print dbint(0) + dbstring(1) + dbfloat(2) end while dbcloseset # rassemble tout dbclose end errortrap: # accepte l'erreur - n'affiche rien - va à la prochaine commande return
affichera
1one3.14 3three9.43 2two6.28
De plus amples informations (en anglais) sur les bases de données en général et SQLite en particulier, sont disponibles aux adresses suivantes : Page d'accueil de SQLite et SQL sur 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
degrees ( expression )
dim numericvariable ( integer )
dim stringvariable$ ( integer )
dim numericvariable ( rows , columns )
dim stringvariable$ ( rows , columns )
Retourne un nouveau tableau à 1 dimension de longueur integer ou à 2 dimensions qui peut être adressé par row et column. Selon l'assignation de la variable, un tableau numérique ou de chaînes de caractères est créé.
Le premier élément d'un tableau a l'index 0 (zéro). Les index allant ainsi de 0 à {longueur}-1.
dim z(5) z = {1, 2, 3, 4, 5} print z[0] + " " + z[4]
affichera
1 5
dim c$(4) c$ = {"à", "bulot, "laque", "L'anneau"} print c$[2] + " " + c$[3] + " "; print c$[1] + " " + c$[0] + "!"
affichera
L'anneau laque à bulot!
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()
Renvoie l'heure courante de l'horloge système (0-23).
# affiche la date dim mois$(12) mois$ = {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} d = day() if d=1 then ier$="er" else ier$="" endif print d + ier$ + " " + mois$[month()] + " " + year() # affiche l'heure print hour() + ":" + right("0" + minute(), 2) + ":" + right("0" + second(), 2)
affichera quelque chose comme ceci :
1er mai 2013 21:47:04
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
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
length( string )
Returns the number of characters in string
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()
Renvoie la minute courante de l'horloge système (0-59).
# affiche la date dim mois$(12) mois$ = {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} d = day() if d=1 then ier$="er" else ier$="" endif print d + ier$ + " " + mois$[month()] + " " + year() # affiche l'heure print hour() + ":" + right("0" + minute(), 2) + ":" + right("0" + second(), 2)
affichera quelque chose comme ceci :
1er mai 2013 21:47:04
0.9.4
month
month()
Renvoie le mois en cours de l'horloge système (0-11 : 0=janvier, 1=février, … 11=décembre).
cls dim les_mois$(12) les_mois$ = {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} d=day() if d=1 then ier$="er" else ier$="" endif print day() + ier$ + " " + les_mois$[month()] + " " + year()
affichera par exemple :
1er mai 2013
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" 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
wait for connection 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
radians ( expression )
rand
rand()
Retourne un nombre au hasard entre 0 et 1. La distribution des valeurs est uniforme.
Pour faire un nombre au hasard entre d'autre nombres, il faut multiplier ou ajouter des nombres appropriés. Example: Pour generer un nombre entier entre 0 et 10, utiliser: 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 commentaire
# commentaire
Ligne de commentaire pour aider à comprendre le code. Une ligne qui commence par rem ou par # est ignorée par BASIC-256.
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 )
Utilise le moteur du système de synthèse vocale (TTS - Text to Speech) pour dire l'expression. Dans GNU/Linux, les bibliothèques FLite ou eSpeak sont nécessaires. Dans Windows, la voix SAPI par défaut actuelle sera utilisée.
0.9.4
second
second()
Renvoie la seconde courante de la minute courante de l'horloge système (0-59).
# affiche la date dim mois$(12) mois$ = {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} d = day() if d=1 then ier$="er" else ier$="" endif print d + ier$ + " " + mois$[month()] + " " + year() # affiche l'heure print hour() + ":" + right("0" + minute(), 2) + ":" + right("0" + second(), 2)
affichera quelque chose comme ceci :
1er mai 2013 21:47:04
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.
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()
Renvoie l'année en cours de l'horloge système sur 4 chiffres.
print "la date du jour est le "; print day() + "/" + (month() + 1) + "/" + year()
affiche
la date du jour est le 1/5/2013
0.9.4