Author Topic: SmallBASIC is a fast and easy to learn BASIC language interpreter Windows/Linux  (Read 1411 times)

0 Members and 1 Guest are viewing this topic.

Software Santa

  • Administrator
  • *****
  • Posts: 4263
  • OS:
  • Mac OS X 10.9 Mac OS X 10.9
  • Browser:
  • SeaMonkey 2.29.1 SeaMonkey 2.29.1
SmallBASIC is a fast and easy to learn BASIC language interpreter for Windows/Linux/Others

Welcome to SmallBASIC Sat, 12/22/2007 - 05:18 - chrisws SmallBASIC is a fast and easy to learn BASIC language interpreter ideal for everyday calculations, scripts and prototypes. SmallBASIC includes trigonometric, matrices and algebra functions, a built in IDE, a powerful string library, system, sound, and graphic commands along with structured programming syntax.
Constants and Variables
  • All user variables (include arrays) are ‘Variant’. That means the data-type is invisible to user.
  • Arrays are always dynamic, even if you had declared their size, with dynamic size and type of elements.
However, SmallBASIC uses, internally, 4 data-types
  • Integer  (32bit)
  • Real     (64bit)
  • String   (<32KB on 16bit / 2GB on 32bit)
  • Array    (~2970 elements on 16bit / ~50M elements on 32bit)
Conversions between those types are performed internally. In any case there are functions for the user to do it manually.
Variable names
Variable names can use any alphanumeric characters, extended characters (ASCII codes 128-255 for non-English languages) the symbol ‘_’, and the symbol ‘$’. The first character of the name cannot be a digit nor a ‘$’.
About the dollar-symbol
The symbol ‘$’ is supported for compatibility. Since in SmallBASIC there are no data-types its use is meaningless.
The dollar in function names will be ignored.
The dollar in variable names will be count as part of the name (that means v and v$ are two different variables). It can be used only as the last character of the name, and only one allowed.
The dollar in system variables names will be ignore it (that means COMMAND and COMMAND$ is the same)
Example of variable names:
abc, a_c, _bc, ab2c, abc$ -> valid names 1cd, a$b, $abc            -> invalid names 
This is the default data type. You can declare integers in decimal, hexadecimal, octal and binary form.
x = 256   ' x = 0x100 ' Hexadecimal form 1 x = &h100 ' Hexadecimal form 2 x = 0o400 ' Octal form 1 x = &o400 ' Octal form 2 x = 0b111 ' Binary form 1 x = &b111 ' Binary form 2 
Any number which out-bounds the limits or an ‘integer’ or had decimal digits will be converted automatically to real.
x = .25 x = 1.2 
Reals can be also written by using scientific notation. 1E+2 or 1E-+2, 5E—2, 2.6E-0.25, etc
Strings may be appended to one another using the + operator.
b = "Hello, " + "world!" 
Constant variables can be declared by using the keyword CONST.
CONST my_pi = 3.14 
System Variables
System variables, are constant variables for the programmer. Those variables get values or modified at run-time by the SB’s subsystem.
  • OSNAME Operating System name
  • OSVER Operating System Version (0xAABBCC (A=major, B=minor, C=patch))
  • SBVER SmallBASIC Version (0xAABBCC)
  • PI 3.14..
  • XMAX Graphics display, maximum x (width-1)
  • YMAX Graphics display, maximum y (height-1) value
  • BPP Graphics display: bits per pixel (color resolution)
  • VIDADR Video RAM address (only on specific drivers)
  • CWD Current Working Directory
  • HOME User’s home directory
  • COMMAND Command-line parameters
  • TRUE The value 1
  • FALSE The value 0
Sorted by priority
( ) Parenthesis
+, – Unary
~ bitwise NOT
NOT or ! Logical NOT  (NOT false = true)
^ Exponentiation
*, /, \ Multiplication, Division, Integer Division
% or MOD Reminder (QB compatible: a=int(a), b=int(b), a-b*(a/b))
MDL Modulus  (a%b+b*(sgn(a)<>sgn(b)))
+, – Addition/Concatenation, Subtraction
= Equal
<> or != Not Equal
>,    < Less Than, Greater Than
=>,   =< Less or Equal, Greater or Equal
>=,   <= Less or Equal, Greater or Equal
IN belongs to … (see “The IN operator”)
LIKE Regular expression match (see “The LIKE operator”)
AND or && Logical AND
OR  or Logical OR
BAND or & bitwise AND
BOR  or bitwise OR
EQV bitwise EQV
IMP bitwise IMP
XOR bitwise XOR
NAND bitwise NAND
NOR bitwise NOR
XNOR bitwise XNOR
Special Characters
&h or 0x Prefix for hexadecimal constant (0×1F,   &h3C)
&o or 0o Prefix for octal constant       (0o33,   &o33)
&b or 0b Prefix for binary constant      (0b1010, &b1110)
[,;] Array definition (function ARRAY)                    ($1)
<< Appends to an array (command APPEND)                   ($1)
++ Increase a value by 1 (x = x + 1)                      ($1)
— Decrease a value by 1 (x = x – 1)                      ($1)
p= Another LET macro (x = x p …). Where p any character of -+/\*^%&
: Separates commands typed on the same line
& Join code lines (if its the last character of the line). The result line its must not exceed the max. line size.
# Meta-command (if its the first character of the line) or prefix for file handle
@ The ‘at’ symbol can by used instead of BYREF          ($1)
‘ Remarks


This Site was Opened on January 1st, 2007

Welcome Visitor:

Spam Harvester Protection Network
provided by Unspam