0 Members and 1 Guest are viewing this topic.
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 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 namesAbout the dollar-symbolabc, a_c, _bc, ab2c, abc$ -> valid names 1cd, a$b, $abc -> invalid names IntegersThis 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 Realsx = .25 x = 1.2 StringsStrings may be appended to one another using the + operator.b = "Hello, " + "world!" ConstantsConstant variables can be declared by using the keyword CONST.CONST my_pi = 3.14 System VariablesOSNAME Operating System nameOSVER 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) valueBPP Graphics display: bits per pixel (color resolution)VIDADR Video RAM address (only on specific drivers)CWD Current Working DirectoryCOMMAND Command-line parametersTRUE The value 1FALSE The value 0 OperatorsSorted by priority ( ) Parenthesis Unary~ bitwise NOTNOT 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 EqualINLIKEAND or && Logical ANDOR or Logical ORBAND or & bitwise ANDBOR or bitwise OREQV bitwise EQVIMP bitwise IMPXOR bitwise XORNAND bitwise NANDNOR bitwise NORXNOR bitwise XNOR Special Characters &h or 0x&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)p=: 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@ Remarks
abc, a_c, _bc, ab2c, abc$ -> valid names 1cd, a$b, $abc -> invalid names
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
x = .25 x = 1.2
b = "Hello, " + "world!"
CONST my_pi = 3.14
Page created in 0.174 seconds with 16 queries.