1/15/13

SmallBASIC Guide
1. Introduction 2. The language 4. Commands 5. System 6. Graphics & Sound 7. Miscellaneous 8. File system 9. Mathematics 10. 2D Algebra 11. Strings 12. Console D. Limits A. Interactive Mode B. MySQL Module C. GDBM Module E. Writting Modules F. Glossary G. GNU Free Documentation License H. Command Index I. Variable Index

[Top ] [Contents ] [Index] [ ? ]

SmallBASIC (SB) is a simple computer language, featuring a clean interface, strong mathematics and string library. We feel it is an ideal tool for experimenting with simple algorithms, for having fun.

1. Introduction
1.1 Welcome to SmallBASIC
SmallBASIC (SB) is a simple computer language, featuring a clean interface, strong mathematics and string library. We feel it is an ideal tool for experimenting with simple algorithms, for having fun.

1.1.1 About BASIC
BASIC is a very simple language and it is a perfect tool for calculations or utilities. Its name stands for (B)eginners (A)ll-purpose (S)ymbolic (I)nstruction (C)ode. It was developed by John Kemeny and Thomas Kurtz at Dartmouth College during the middle of 1960, and was one of the most popular languages for several decades. However, at the last decades it was upgraded to survive on the new programming environments. It was modernized and that was hard required.
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 1/89

1/15/13

SmallBASIC Guide:

In the first upgrade, BASIC was transformed to a structured language. As far, as I known, the first structured BASIC was the QuickBASIC (QB), a Microsoft product. Several structured dialects was followed from other companies. In the second upgrade, BASIC was transformed to an (almost) object-oriented language. As far, as I known, the first OO BASIC was the VisualBASIC (VB), a Microsoft product. In that stage BASIC was become very problematic, since, Microsoft was introduced ObjectPascal and C++ technologies in a language with very different design and purpose of existance! Anyway, we strongly disagree with the "new" feautures and the way that are implemented in VB. Every language created for specified purposes, BASIC for beginners, C for low-level programming, Prolog for AI, etc. VB it is not object-oriented nor a simple language (anymore), but it is a bad designed mix of other languages.

1.1.2 About SmallBASIC
SmallBASIC was created by Nicholas Christopoulos in May of 2000, to be used as an advanced calculator for his Palm IIIx handheld device. In Jan of 2001, SB moved to the web as an GPL project. Because SB was designed for that small device (Palm IIIx), and because was small compared to desktop-computer BASICs, it takes the prefix 'Small'. SB is a structured version of BASIC and includes a lot of new feautures such matrices, algebra functions, powerfull string library, etc. A lot of its feautures does not exists in the most languages, but on the other hand, SB does not supports GUI and other feautures that are common in today languages.

1.1.2.1 Purpose
BASIC is easy to learn and simple to use, and this is the spirit of SB. Instead of other BASIC versions, as VB, our version intent to sucrifice everything in the altar of simplicity. The world is full of languages, SB does not offers something new, but intents to offer what is lost in our days. A simple tool for easy to write programs, an easy way to do some maths and build some scripts. Our priorities are to build An extremly easy learned language. An extremly easy to use language. An ideal tool for experimenting on programming. An excellent tool for mathematics. An excellent tool for shell-scripts.

1.1.2.2 Cross-platform
Now, SB can run on more platforms than PalmOS, such Linux, DOS, Win32, EBM and VTOS. An mechanism had inserted and porting to different platforms is an easy task. For this reason, SB claims that it is a cross-platform language.
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 2/89

1/15/13

SmallBASIC Guide:

However, SB is based primary on Unix systems. A lot of feautures (for example, Units, C-Modules) does not implemented on other systems yet.

1.2 Useful notes for beginners
1.2.1 What we must already know
Integer Number A number that does not have a fractional part. Floating-Point Number Real Number Often referred to in mathematical terms as real number, this is just a number that can have a fractional part. Numeric Constants Numeric constants may be entered with any number of digits. For extremly large or small numbers, it is usually more convenient to use scientific notation. In scientific notation, a number is given as a mantissa (a number with one place to the left of the decimal point) times 10 raised to an integer power. Scientific Notation Examples:
1 5 1 5 0 1 5 0 0 1 5 0 0 0 . 1 5 i se x p r e s s e da s1 . 5 * 1 0 ^ 1 , i st y p e da s1 . 5 E + 1 i se x p r e s s e da s1 . 5 * 1 0 ^ 2 , i st y p e da s1 . 5 E + 2 i se x p r e s s e da s1 . 5 * 1 0 ^ 3 , i st y p e da s1 . 5 E + 3 i se x p r e s s e da s1 . 5 * 1 0 ^ 3 ,i st y p e da s1 . 5 E + 3 i se x p r e s s e da s1 . 5 * 1 0 ^ 1 ,i st y p e da s1 . 5 E 1

Numeric Expressions Numeric expressions are constructed from numeric constants, variables, and functions using the arithmetic operators for addition (+), substraction (-), multiplication (*), division (/) and exponentiation (^). The minus sign (-) can be used either to indicate subtraction or as a unary minus. The normal hierarchy for evaluating a numeric expression is exponentiation, followed by multiplication and division, and then by addition and subtraction. However, any part of a numeric expression that is enclosed in parenthesis is evaluated first. In SB more operators are supported. For further reading please see 'Operators' section. String A datum consisting of a sequence of characters, such as `‘I a mas t r i n g ’'. String Constants String constants are the texts enclosed in double quotation marks, like this:
" Ia mas t r i n gc o n s t a n t ! "

String Expressions String expressions are constructed from string variables, string constants, and function references using the operation for concatenation (+) to combine strings. Example:
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 3/89

1/15/13

SmallBASIC Guide:

x=" H I "+"T H E R E ! "

In this example, the 〈x 〉 is equal to "HI THERE!". Relational Expressions Relational expressions are most often used in the IF-THEN statement, but may be used anywhere that numeric expressions are allowed. A relational expression has a value of nonzero if it is true and a value of 0 if it is false. Relational operators are performed, from left to right, after all arithmetic operations are completed. The most usual relational operators are:
E q u a lt o( = ) , N o te q u a lt o( < > ) L e s st h a n( < ) , L e s st h a no re q u a lt o( < = ) G r e a t e rt h a n( > ) ,G r e a t e rt h a no re q u a lt o( > = )

Boolean Expressions (also known as Logical Expressions) Named after the English mathematician Boole. Logical expressions are used usual with relational expressions. The logical operators are AND, OR and NOT. If true, logical expressions are given a value of non-zero. If false, they are given a value of 0. A logical expression using A N Dis true if both its left and right clauses are true. A logical expression using O Ris true if either its left or its right, or both, clauses are true. A logical expression using N O Tis true if the following clause it is not true. Variable A variable is a name which represents a value. Actually the value exists in memory, a variable represent the memory space that holds the value. Array A grouping of multiple values under the same variable. Keyword In a language, a keyword is a word that has special meaning. Keywords are reserved and may not be used as variable names. Statement An important unit of the language Command Also, known as build-in procedure Comment ... Assignment An expression that changes the value of some variable. The value that you can assign to is called an lvalue. The assigned values are called rvalues. Procedure Routine SubRoutine A specialized group of statements used to encapsulate general or program-specific tasks. SB has a number of built-in procedures, and also allows you to define your own. In older times those groups of statements was called routines. This is why the 'procedures' are called S U B (routines) in BASIC.

w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44

4/89

b F O Oa . Everything is written inside of { } characters means you must select one of them.2. or newline characters occurring inside an input record or a string. ] ] This means that you must use the first parameter.. Space The character generated by hitting the space bar on the keyboard. SB has a number of built-in functions.users. TAB. Example #1: F O O < -T h i si sk e y w o r d F O O ( ) < -T h i si sf u n c t i o n f o o < -T h i si sv a r i a b l e / p a r a m e t e r f o o ( ) < -T h i si sa r r a y / p a r a m e t e r { A | B } < -T h i sm e a n st h a ty o um u s tt y p eAo rB [ { A | B } ]< -T h i sm e a n st h a ty o um u s tu s eAo rBo rn o t h i n g Example #2: F O Oa [ .' or '.c w ired_gr. . The symbol | means OR. Tab The character generated by hitting the eight or four spaces upon output. vertical tab.'.html#SEC44 5/89 . The parameters with suffix ( ) are arrays.b F O Oa . . You can also use second parameter but you must separate it with '. function can return a value and can be used inside expressions. It usually expands to up to Whitespace A sequence of space. means you can repeat the previous syntax. The difference between function and procedure is that. | . from-feed. TAB key on the keyboard. The keywords with suffix ( ) are functions.x ] This means that you must give the first parameter (a) but you can use the second (x) only if you want to. The keywords are written with capital letters. You can also repeat the last syntax more times The following code respects this syntax F O Oa F O Oa .1/15/13 SmallBASIC Guide: Function A specialized group of statements used to encapsulate general or program-specific tasks. Example #3: F O Ov a r[ { . Procedure can't do that. The symbols . The parameters are written with lower letters.. and also allows you to define your own.net/doc/sb9/guide. But if you want to use the (x) you must also separate it from (a) with a comma.2 How to read the syntax Everything is written inside of [ ] characters are optional values. 1. }v a r 2[ .sourceforge.b .

type C L S ENTER .g Example #4: 'S y n t a x :T E S T{ 1 | 2 } T E S T1 T E S T2 'S y n t a x :T E S T[ H I ] T E S T T E S TH I 1.1/15/13 SmallBASIC Guide: F O Oa .sourceforge. The screen will be cleared. Now.net/doc/sb9/guide. 0 C o p y r i g h t( c )2 0 0 0 2 0 0 3N i c h o l a sC h r i s t o p o u l o s T y p e' H E L P 'f o rh e l p . / h o m e / n i k o s c >r u n A r ey o ur e a d y t ol e a r nB A S I C ? *D O N E* / h o m e / n i k o s c > Now. / h o m e / n i k o s c >l i s t 1 0 :P R I N T" A r ey o ur e a d y " 2 0 :P R I N T" t ol e a r nB A S I C ? " 3 0 :E N D / h o m e / n i k o s c > w ired_gr. *R E A D Y* / h o m e / n i k o s c > Type the following program. Use RIGHT-ARROW or LEFT-ARROW to move inside the line. type R U N ENTER .t y p e' B Y E 'o rp r e s sC t r l + Cf o re x i t . 9 . DOS or Win32 Console). pressing 1 0P R I N T" A r ey o ur e a d y " 2 0P R I N T" t ol e a r nB A S I C ? " 3 0E N D ENTER at the end of each program line. Fix the problem and press ENTER .3 Running SB Interactively Interactive mode is supported only on console mode (Unix. use UP-ARROW or DOWN-ARROW to find the previously typed lines.c F O Oa .b .b . a prompt appears at which we can run any OS command or starting typing the program.html#SEC44 6/89 . When you are ready to see the program in action. The SmallBASIC is started by typing s b a s i c .d . When the SB starts.e . Check the program now to see if there are any typing mistakes.users.f .c . #s b a s i c S m a l l B A S I CV E R S I O N0 . If there are. type L I S T ENTER to see your program lines.

users.html#SEC44 7/89 .4. usefull when we want to do some temporary calculations. run SB by using the file-name as parameter. / m y p r o g . b a s '.sb P R I N T" P R I N T3 / 4 " Now. save it and exit from the editor. Typically an SB program file must be terminated with `. s b|s b a s i cq 0 . Those script are working similar to the common executables. 7 5 # We did something very simple. this program prints out the P R I N T3 / 4text.4 Running SB The usual way is type our program to an editor and save that in a file. 1. There are also more advanced ways to run a program with SB. s b H e l l o . It is also give us a taste of the old times. type a program that prints out SB commands! myprog. Type some commands like our previous example. s b Now we can run it as usual. for example `m y p r o g . #. Now. For example.1/15/13 SmallBASIC Guide: This is the simpliest way to run SB.net/doc/sb9/guide. 1. s b ' or `. Give to them a name.1 Unix script executables In Unices we can create script executables. s b H e l l o . run it by using | (pipe) symbol. s b '. a) A line at the beginning of our program # ! / u s r / b i n / s b a s i cq b) And sets the executable attribute of the file #c h m o d0 7 7 7m y p r o g . s b '.w o r l d ! # w ired_gr. #s b a s i cqm y p r o g . Create a file with an editor like j o e .sourceforge. That helps the OS to understand the type of the file.k a t eor E D I T .w o r l d ! # The -q option tells to SB to be quite. The second s b a s i cwas execute the result of the first s b a s i cwhich was the code P R I N T3 / 4 . The first sbasic runs the `m y p r o g . We need only two things. #s b a s i cqm y p r o g .

1/15/13 We can find more on scripts. Real (64bit) 3. 2. extended characters (ASCII codes 128-255 for non-English languages) the symbol '_'. However. The dollar in system variables names will be ignore it (that means COMMAND and COMMAND$ is the same) Example of variable names: w ired_gr.1. 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. Since in SmallBASIC there are no data-types its use is meaningless. 2.1.html#SEC44 8/89 . 2. Arrays are always dynamic.1 Variable names Variable names can use any alphanumeric characters.users. 4 data-types 1. That means the data-type is invisible to user. SmallBASIC uses. internally.sourceforge. and only one allowed. paths and Unix attributes on Unix manuals. In anycase there are functions for the user to do it manualy. String (<32KB on 16bit / 2GB on 32bit) 4. even if you had declared their size. Array (~2970 elements on 16bit / ~50M elements on 32bit) Convertions between those types are performed internaly. Integer (32bit) 2. and the symbol '$'. The first character of the name cannot be a digit nor a '$'.net/doc/sb9/guide. User-defined data types are not allowed.1 Constants and Variables All user variables (include arrays) are 'Variant'. with dynamic size and type of elements. The language This chapter documents language structure. 2.2 About the dollar-symbol The symbol '$' is supported for compatibility.

a $ b ._ b c .6 Constants Constant variables can be declared by using the keyword CONST C O N S Tm y _ p i=3 .1.html#SEC44 9/89 . x=.$ a b c >i n v a l i dn a m e s 2. 1E+2 or 1E-+2.a _ c .users."+" w o r l d ! " 2. 2 Reals can be also written by using scientific notation.2 System Variables w ired_gr.1. 5E--2.25.4 Reals Any number which out-bounds the limits or an 'integer' or had decimal digits will be converted automatically to real.1.sourceforge.1/15/13 a b c .3 Integers This is the default data type. x=2 5 6 ' x=0 x 1 0 0'H e x a d e c i m a lf o r m1 x=& h 1 0 0'H e x a d e c i m a lf o r m2 x=0 o 4 0 0'O c t a lf o r m1 x=& o 4 0 0'O c t a lf o r m2 x=0 b 1 1 1'B i n a r yf o r m1 x=& b 1 1 1'B i n a r yf o r m2 2.6E-0. 2. hexadecimal.net/doc/sb9/guide. You can declare integers in decimal. etc 2. b=" H e l l o .5 Strings Strings may be appended to one another using the + operator. 2 5 x=1 .1.a b c $>v a l i dn a m e s 1 c d . 1 4 2.a b 2 c . octal and binary form.

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 2. Subtraction Equal Not Equal Less Than. Integer Division Modulus (a%b+b*(sgn(a)<>sgn(b))) Addition/Concatenation. <= IN Parenthesis Unary bitwise NOT Logical NOT (NOT false = true) Exponentiation Multiplication. C=patch)) SmallBASIC Version (0xAABBCC) 3. Greater or Equal Less or Equal. Greater Than Less or Equal. B=minor. 〈 XMAX〉 Graphics display. Greater or Equal belongs to . ~ NOT or ! ^ *.users. 〈 OSNAME〉 〈 OSVER〉 〈 SBVER〉 〈 PI〉 Operating System name Operating System Version (0xAABBCC (A=major. a-b*(a/b)) w ired_gr. b=int(b).. (see "The IN operator") 10/89 % or MOD Reminder (QB compatible: a=int(a). Division. Those variables get values or modified at run-time by the SB's subsystem.html#SEC44 ..3 Operators Sorted by priority () +..14. = <> or != >. < =>. are constant variables for the programmer. \ MDL +.sourceforge.net/doc/sb9/guide. /.1/15/13 SmallBASIC Guide: System variables. =< >=. maximum x (width-1) 〈 YMAX〉 Graphics display.

and the compile-time (like PREDEF) which used only in compile-time and the value cannot be changed on run-time.] << ++ -p= : & # @ ' 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 .). Where p any character of -+/\*^%& Separates commands typed on the same line Join code lines (if its the last character of the line).1) ($1) Another LET macro (x = x p . line size..4 Special Characters &h or Prefix for hexadecimal constant (0x1F. 2.1/15/13 SmallBASIC Guide: LIKE OR or || BOR or | EQV IMP XOR NAND NOR XNOR Regular expression match (see "The LIKE operator") Logical OR bitwise OR bitwise EQV bitwise IMP bitwise XOR bitwise NAND bitwise NOR bitwise XNOR AND or && Logical AND BAND or & bitwise AND 2. These operators are replaced by compiler with a command or an expression... 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 $1 Pseudo operators. &b1110) 0b [. The result line its must not exceed the max.5 The OPTION keyword Statement: OPTION keyword parameters This special command is used to pass parameters to the SB-environment. &h3C) 0x &o or Prefix for octal constant (0o33. There are two styles for that.html#SEC44 . the run-time (like BASE) which can change the value at run-time. &o33) 0o &b or Prefix for binary constant (0b1010.sourceforge.net/doc/sb9/guide. w ired_gr.users.

users. there is no extra code on compiler which means that SB compiles the pattern everytime it is used.' Examples w ired_gr.5. Directories on Unix must separated by ':'. Example: (Clie HiRes) O P T I O NP R E D E FG R M O D E3 2 0 x 3 2 0 x 1 6 `‘T E X T M O D E ’' Sets the text mode flag (-g. The O P T I O NB A S Estatement can be used in any place in the source code but that is the wrong use of this except if we have a good reason.html#SEC44 12/89 .6 Meta-commands Macro: #!. Matching-algorithm is used in L I K Eand F I L E S . 2. The default is zero.. With a few words DO NOT USE IT! Macro: #inc: file Used to include a SmallBASIC source file into the current BASIC code Macro: #unit-path: path Used to setup additional directories for searching for unit-files This meta does nothing more than to setting up the environment variable SB_UNIT_PATH.. and on DOS/Windows by '. Where 〈parameter〉 `‘Q U I T E ’' Sets the quite flag (-q option) `‘C O M M A N Dc m d s t r ’' Sets the C O M M A N D $string to 〈cmdstr〉 (useful for debug reasons) `‘G R M O D E[ w i d t h x h e i g h t [ x b p p ] ] ’' Sets the graphics mode flag (-g option) or sets the prefered screen resolution.1/15/13 SmallBASIC Guide: 2. Sections names are used at limited OSes like PalmOS for multiple 32kB source code sections.option) `‘C S T R ’' Sets as default string style the C-style special character encoding ('\') 2.1 Run-Time Statement: OPTION BASE lower-bound The O P T I O NB A S Estatement sets the lowest allowable subscript of arrays to 〈lower-bound〉. Statement: OPTION MATCH {PCRE [CASELESS]|SIMPLE} Sets as default matching algorithm to (P)erl-(C)ompatible (R)egular (E)xpressions library or back to simple one. In most cases the O P T I O N B A S Emust declared at first lines of the program before any D I Mdeclaration.sourceforge.5. PRCE works only in systems with this library and it must be linked with. Also. Used by Unix to make source runs as a script executable Macro: #sec: section-name Used internally to store the section name.2 Compile-Time Statement: OPTION PREDEF parameter Sets parameters of the compiler.net/doc/sb9/guide.

A=[. b a s " .3 1 . .3 . M y L i b P r o c" H i " 2.net/doc/sb9/guide.2 1 . .1/15/13 .7 .2 2 . .6 .3 .4 .3 2 ] That creates the array |1 1 1 2| |2 1 2 2|=A |3 1 3 2| The comma used to separate column items.8 ] A=B+C C=A-B Equal: b o o l = ( A = B ) Unary: A 2=A Multiplication: A=[ 1 .2 . the semi-colon used to separate rows.sourceforge.5 ] This creates the array |0 0 0| |1 2 0|=A |3 4 5| Supported operators: Add/sub: B=[ 1 .4 ] :C=[ 5 .3 .2 .1 2 . .6 ] C=A*B w ired_gr.4 ] :B=[ 5.1 . # i n c : " m y l i b .7 Arrays and Matrices Define a 3x2 matrix A=[ 1 1 .2. Values between columns can be omitted.users.html#SEC44 13/89 ..

1 .8 Nested arrays Nested arrays are allowed A=[ [ 1 .9 ] C=L i n E q n ( A . y . 3 ) |123|=A For vertical arrays you must declare it as 2-dim arrays Nx1 D I MA ( 3 .2 .2 . for multiplication) So the default is columns D I MA ( 3 )'o rA ( 1 .1 . 1 ) |1| |2|=A |3| 2.1 .5 .3 . because 1-dim arrays does not specify how SmallBASIC must see them. z ]=" .2 . (ex. D I MA ( 3 ) |123|=A o r |1| |2|=A |3| And because this is not the same thing.5 .D=0 .3 .6 ] B=[2 .[ 3 .2 .B ) ?" [ x .1 ] ?I N V E R S E ( A ) Gauss-Jordan: ?" S o l v et h i s : " ?" 5 x-2 y+3 z=2 " ?"2 x+7 y+5 z= 7 " ?" 3 x+5 y+6 z= 9 " ? A=[5 .C There is a problem with 1 dimension arrays. 8*A Inverse: A=[1 . 2 ]. 4 ] ] B=[ 1 .5 ] B ( 2 )=C p r i n tB .3 ] C=[ 4 .3 .7 .2 .2 .7 .

9 The operator IN IN operator is used to compare if the left-value belongs to right-value. .html#SEC44 15/89 . [!SET] or [^SET] matches any character not in the specified set. It is compares the left part of the expression with the pattern (right part).c. DIRWALK) too. 1991). The same code is used for filenames (FILES().1/15/13 SmallBASIC Guide: p r i n tB This will be printed [ 1 .sourceforge.net/doc/sb9/guide.3 ] You can access them by using a second (or third. 'U s i n gi tw i t hn u m b e r( t r u eo n l yi fl e f t=r i g h t ) p r i n t1 1i n2 1 : R E MF A L S E p r i n t1 1i n1 1 : R E MT R U E . Kercheval (match. In the pattern string: * ? [SET] matches any sequence of characters (zero or more) matches any character matches any character in the specified set.[ 4 ." b " . 'U s i n gi tw i t hs t r i n g s p r i n t" n a "i n" a b c d e " : R E MF A L S E p r i n t" c d "i n" a b c d e " : R E MT R U E . .2 . (see OPTION). B ( 2 ) ( 1 )=1 6 p r i n tB ( 2 ) ( 1 ) R e s u l t : 1 6 2.5 ] . 2 ] : R E MT R U E p r i n t" b "i n[ " a " . But there is an option to use PCRE (Perl-Compatible Regular Expression library) on systems that is supported (Linux). Since the original regular expression code is too big (for handhelds).10 The operator LIKE LIKE is a regular-expression operator. w ired_gr. 's p e c i a lc a s e 'a u t o c o n v e r ti n t e g e r s / r e a l s p r i n t1 2i n" 2 3 4 5 6 7 " : R E MF A L S E p r i n t1 2i n" 3 4 1 2 5 6 " : R E MT R U E 2. . etc) pair of parenthesis. based on an excellent old stuff by J. 'U s i n gi tw i t ha r r a y s p r i n t1i n[ 2 . ." c " ]: R E MT R U E . . 3 ] : R E MF A L S E p r i n t1i n[ 1 .users. public-domain. . I use only a subset of it.

] ] ] [ E X I TS U B ] . 'P a s s i n g' x 'b yv a l u e S U BF ( x ) x = 1 E N D w ired_gr. ?" H e l l o "L I K E" * [ o O ] ":R E MT R U E ?" H e l l o "L I K E" H e ? ? o ":R E MT R U E ?" H e l l o "L I K E" h e l l o ":R E MF A L S E ?" H e l l o "L I K E" [ H h ] * ":R E MT R U E 2. .. and match the character exactly. .v a r [ .net/doc/sb9/guide.html#SEC44 16/89 . ..12 Subroutines and Functions Syntax of procedure (SUB) statements S U Bn a m e[ ( [ B Y R E F ]p a r 1[ . . [ B Y R E F ]p a r N ) ] ] [ L O C A Lv a r [ . Use B Y R E Fkeyword for passing parameters 'by reference'.11 The pseudo-operator << This operator can be used to append elements to an array. [0-9a-zA-Z_] is the minimal set of characters allowed in the [. Passing parameters by value means the executor makes a copy of the parameter to stack. The parameters are 'by value' by default. E N D Syntax of function (FUNC) statements F U N Cn a m e [ ( [ B Y R E F ]p a r 1[ . . Passing parameters by reference means the executor push the pointer of variable into the stack.users. the function-name acts like a variable and it is the function's returned value. precede it with a `\'. ] ] ] [ E X I TF U N C ] . a range looks like character hyphen character (as in 09 or A-Z). n a m e = r e t u r n v a l u e E N D On functions you must use the function's name to return the value. The value in caller's code will not be changed. That is.. [ B Y R E F ]p a r N ) ] ] [ L O C A Lv a r [ .. . To suppress the special syntactic significance of any of `[]*?!^-\'.1/15/13 SmallBASIC Guide: A set is composed of characters or ranges.. . . The value in caller's code will be the changed. .] pattern construct.v a r [ . A< <1 A< <2 A< <3 ?A ( 1 ) 2. . . .sourceforge.

html#SEC44 'M A I N 17/89 . L O C A Lcreates variables (dynamic) at routine's code. . S U BF ( @ x ) x = 1 E N D On a multi-section (PalmOS) applications sub/funcs needs declaration on the main section. There is no difference between @ and B Y R E F . e n d Use the L O C A Lkeyword for local variables. S U BF B R ( B Y R E Ft b l ) ?F R E ( 0 ) .users. E N D w ired_gr. E N D S U BF B V ( t b l ) ?F R E ( 0 ) . otherwise their data will be duplicated in memory space. . When using arrays as parameters its better to use them as B Y R E F .sourceforge. .1/15/13 SmallBASIC Guide: x = 2 Fx ?x : R E Md i s p l a y s2 'P a s s i n g' x 'b yr e f e r e n c e S U BF ( B Y R E Fx ) x = 1 E N D x = 2 Fx ?x : R E Md i s p l a y s1 You can use the symbol '@' instead of B Y R E F . . . # s e c : M a i n d e c l a r ef u n cf ( x ) # s e c : a n o t h e rs e c t i o n f u n cf ( x ) . S U BM Y P R O C L O C A LN : R E ML O C A LV A R N = 2 ?N : R E Md i s p l a y s2 E N D N = 1 : R E MG L O B A LV A R M Y P R O C ?N : R E Md i s p l a y s1 You can send arrays as parameters. .net/doc/sb9/guide.

14 Nested procedures and functions One nice feauture.. . There is no way to access a global procedure with the same name of a local. ] ) ]=e x p r e s s i o n D E FM y S i n ( x )=S I N ( x ) ?M y S i n ( p i / 2 ) 2. . Syntax: F U N Cn a m e [ ( p a r 1 [ . ] ) ]=e x p r e s s i o n o r D E Fn a m e [ ( p a r 1 [ . yet.. The nested procedures/functions are visible only inside the "parent" procedure/function.. This is actually a macro for compatibility with the BASIC's DEF FN command. are the nested procedures/functions.i d i mb ( 1 6 ) f o ri = 0t o1 6 b ( i ) = 1 6 a ( i ) n e x t f i l l = b e n d D I Mv ( ) v = f i l l ( v ) 2. f u n cf i l l ( a ) l o c a lb .13 Single-line Functions There is also an alternative F U N C /D E Fsyntax (single-line functions).. F U N Cf ( x ) R e mF u n c t i o n :F / F 1 ( ) F U N Cf 1 ( x ) R e mF u n c t i o n :F / F 1 / F 2 ( ) F U N Cf 2 ( x ) f 2 = c o s ( x ) E N D f 1=f 2 ( x ) / 4 E N D R e mF u n c t i o n :F / F 3 ( ) w ired_gr.1/15/13 'M A I N D I Md t ( 1 2 8 ) .sourceforge.html#SEC44 . ?F R E ( 0 ) F B Rd t ?F R E ( 0 ) F B Vd t ?F R E ( 0 ) Passing & returning arrays. . . . . .net/doc/sb9/guide.users. but quite usefull. . using local arrays.

sourceforge.bas: U N I TM y U n i t E X P O R TF .users. . a point and the name of the member. M y F ( 1 / 1 . procedure or variables which we want to be visible to another programs must be declared with the E X P O R Tkeyword. U N I TM y U n i t The functions. U N I TM y U n i t E X P O R TM y F . To link a program with a unit we must use the I M P O R Tkeyword. P R I N TM y U n i t . I M P O R TM y U n i t .15 Units (SB libraries) * Linux ONLY for now * Units are a set of procedures. functions and/or variables that can be used by another SB program or SB unit. 6 ) Full example: file my_unit.net/doc/sb9/guide. F U N CM y F ( x ) . E N D * Keep file-name and unit-name the same. I M P O R TM y U n i t To access a member of a unit we must use the unit-name. . . .V R E Mas h a r e df u n c t i o n F U N CF ( x ) F=x * x w ired_gr. The main section of the unit (commands out of procedure or function bodies) is the initialization code.html#SEC44 19/89 . .F U N Cf 3 f 3 = f 1 ( p i / 2 ) E N D R E M ?f 1 ( p i ):R E MO K ?f 2 ( p i ):R E ME R R O R f=x+f 1 ( p i )+f 3:R E MO K E N D 2. . A unit declared by the use of U N I Tkeyword. That helps the SB to automatically recompile the required units when it is needed.

every element of V() will be 'trimmed'. vU S ET R I M ( x ) In that example.1/15/13 SmallBASIC Guide: E N D R E Man o n s h a r e df u n c t i o n F U N CI ( x ) I=x + x E N D R E MI n i t i a l i z a t i o nc o d e V = " Ia mas h a r e dv a r i a b l e " L = " Ia mi n v i s i b l et ot h ea p p l i c a t i o n " P R I N T" U n i t' M y U n i t 'i n i t i a l i z e d: ) " file my_app. If the expression needs more parameter.operators are used to increase or decrease the value of a variable by 1.sourceforge.net/doc/sb9/guide. Example: S P L I Ts . F ( 2 ) 2.users. you can use also the names y and z w ired_gr. "" .17 The USE keyword This keyword is used on specific commands to passing a user-defined expression.16 The pseudo-operators ++/--/p= The ++ and -.html#SEC44 20/89 . x=4 x+ +:R E Mx< -x+1=5 x-:R E Mx< -x-1=4 The generic p= operators are used as in C Where p any character of -+/\*^%&| x+ =4:R E Mx< -x+4 x* =4:R E Mx< -x*4 All these pseudo-operators are not allowed inside of expressions y=x+ +'E R R O R z=( y + = 4 ) + 5'A L S OE R R O R 2. Use the x variable to specify the parameter of the expression. V P R I N TM y U n i t .bas: I M P O R TM y U n i t P R I N TM y U n i t .

. . . F U N CF ( x ) L O C A Li F O Ri = 1T O6 . .2. 3. Weird code may be faster but it is not good. That it is WRONG but as I said . N E X T E N D F O Ri = 1T O1 0 P R I N TF ( i ) N E X T In this example. ./proc. but is not suggested. 3. it can be used by IF command (instead of THEN). because the 〈i〉 of the main loop will always (except the first time) have the value 6! This problem can be solved if we use the L O C A Lkeyword to declare the 〈i〉 in the function body.. . Programming Tips Programmers must use clean and logical code. N E X T E N D F O Ri = 1T O1 0 P R I N TF ( i ) N E X T It is good to declare all local variables on the top of the function.1 Using L O C A Lvariables When a variable is not declared it is by default a global variable. . the result is a real mess. It can be used with WHILE and FOR-family commands.18 The DO keyword This keyword is used to declare single-line commands. t x t " )D OP R I N Tf . For compatibility reasons. Example: F O RfI Nf i l e s ( " * . variables are not declared as 'local' by default. F U N CF ( x ) F O Ri = 1T O6 . the func. compatibility. A usual problem is that name may be used again in a function or procedure. W H I L Ei<4D Oi+ + Also..

Also. i=i+1 U N T I Li>1 0 Initializing the variables at the top of the loop. . and can protect us from usual pitfalls such as forgeting to giving init value or re-run the loop without reset the variables.net/doc/sb9/guide. Instead of the keyword we can use the symbol ' or the #. That is WRONG but it is supported by BASIC and many other languages.3 Loops and expressions FOR-like commands are evaluate the 'destination' everytime. Commands Statement: REM comment Adds explanatory text to a program listing. t x t " ) ) 1 F O Ri = 0T Oi d e s t P R I N Ti N E X T Of course. 〈comment 〉 commentary text.html#SEC44 22/89 . #o n em o r ec o m m e n t w ired_gr.txt"))-1 For each value of i the destination will be evaluated. ignored by BASIC. . . So.1/15/13 SmallBASIC Guide: 3. 4. . loops are evaluate the exitexpression everytime too. R E Ma n o t h e rc o m m e n t . . F O Ri = 0T OL E N ( F I L E S ( " * . i=0 R E P E A T . it is much better to be rewritten as i d e s t = L E N ( F I L E S ( " * .2 Loops and variables When we write loops it is much better to initialize the counters on the top of the loop instead of the top of the program or nowhere. it is much faster too. can make code better readable.sourceforge. The # can be used as remarks only if its in the first character of the line. 3. Example: 'T h a tt e x t l i n ei sj u s taf e wr e m a r k s . t x t " ) ) 1 P R I N Ti N E X T In that example the 'destination' is the LEN(FILES("*.users. .

The L E Tis optional. R E MT h r e ed i m e n s i o na r r a y D I MA ( 1T O6 . 〈 var〉 〈 expr〉 A valid variable name. If the 〈lower〉 is not specified. .1T O8 ) . the 'numeric' and the 'alphanumeric'. A label is a mark at this position of the code. 'Numeric' labels does not needed the keyword L A B E L .]) [. only. .. There are two kinds of labels. w ired_gr.s t a r t i n gf r o m0 D I MA ( 6 ) . Example: C O S N TG=6 . R E MO n ed i m e n s i o na r r a yo f6e l e m e n t s . .1/15/13 SmallBASIC Guide: Statement: LET var = expr Assigns the value of an expression to a variable. . and the O P T I O NB A S Ehasn't used. . .net/doc/sb9/guide. 6 7 2 5 9 E 1 1 Statement: DIM var([lower TO] upper [. . Example: R E MO n ed i m e n s i o na r r a yo f7e l e m e n t s ..s t a r t i n gf r o m1 D I MA ( 1T O6 ) .html#SEC44 23/89 . .users. . . D I Mv ( 4 ) z = v 'W i t h o u tt h eL E Tk e y w o r d 'A s s i g ns t r i n g 'A s s i g na r r a y( z=c l o n eo fv ) Statement: CONST name = expr Declares a constant. The value assigned to variable." T h ef i r s te l e m e n t " Statement: LABEL name Defines a label. R E MA l l o c a t i n gz e r o l e n g t ha r r a y s : D I Mz ( ) ..] The D I Mstatement reserves space in computer's memory for arrays. . with or without operators. but 'alphanumeric' does. Example: L E Tx=4 x=1 z=" S t r i n gd a t a " . The array will have (upper-lower)+1 elements. An expression consisting of literals. I FL E N ( Z ) = 0T H EA P P E N DZ . 〈 name〉 〈 expr〉 An identifier that follows the rules for naming BASIC variables.sourceforge.1T O4 .. the arrays are starting from 0. .

1/15/13

SmallBASIC Guide:

Example:
1 0 0 0?" H e l l o " . . . L A B E LA l p h a L a b e l :?" H e l l o " . . . G O T O1 0 0 0 G O T OA l p h a L a b e l

Statement: GOTO label Causes program execution to branch to a specified position (label). Statement: GOSUB label Causes program execution to branch to the specified label; when the R E T U R Ncommand is encountered, execution branches to the command immediately following the most recent G O S U Bcommand. Statement: RETURN Execution branches to the command immediately following the most recent G O S U Bcommand.
. . . G O S U Bm y _ r o u t i n e P R I N T" R E T U R Ns e n tm eh e r e " . . . L A B E Lm y _ r o u t i n e P R I N T" Ia mi nm yr o u t i n e " R E T U R N

Statement: ON {GOTO|GOSUB} label1 [, ..., labelN] Causes BASIC to branch to one of a list of labels.

〈 expr〉
A numeric expression in the range 0 to 255. Upon execution of the ON...GOTO command (or ON...GOSUB), BASIC branches to the nth item in the list of labels that follows the keyword GOTO (or GOSUB). Statement: FOR counter = start TO end [STEP incr] ... NEXT Begins the definition of a FOR/NEXT loop.

〈 counter〉 〈 start 〉 〈 end〉 〈 incr〉
A numeric variable to be used as the loop counter. A numeric expression; the starting value of counter. A numeric expression; the ending value of counter. A numeric expression; the value by which counter is incremented or decremented with each iteration of the loop. The default value is +1. BASIC begins processing of the FOR/NEXT block by setting counter equal to start. Then, if 'incr' is positive and counter is not greater than end, the commands between the FOR and the NEXT are executed. When the NEXT is encountered, counter is increased by 'incr', and the process is repeated. Execution passes to the command following the NEXT if counter is greater than end. If increment is negative, execution of the FOR/NEXT loop is terminated whenever counter becomes less than end.
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 24/89

1/15/13

FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR. Example:
F O RC = 1T O9 P R I N TC N E X T

Statement: FOR element IN array ... NEXT Begins the definition of a FOR/NEXT loop.

〈 element 〉 〈 array〉
A variable to be used as the copy of the current element. An array expression The commands-block will repeated for LEN(array) times. Each time the 'element' will holds the value of the current element of the array. FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR. Example:
A = [ 1 , 2 , 3 ] F O REI NA P R I N TE N E X T . . . 'T h i si st h es a m ew i t ht h a t A = [ 1 , 2 , 3 ] F O RI = L B O U N D ( A )T OU B O U N D ( A ) E = A ( I ) P R I N TE N E X T

Statement: WHILE expr ... WEND Begins the definition of a WHILE/WEND loop.

〈 expr〉
An expression BASIC starts by evaluating expression. If expression is nonzero (true), the next command is executed. If expression is zero (false), control passes to the first command following the next W E N Dcommand. When BASIC encounters the W E N Dcommand, it reevaluates the expression parameter to the most recent W H I L E . If that parameter is still nonzero (true), the process is repeated; otherwise, execution continues at the next command. WHILE/WEND loops may be nested to any level of complexity, but there must be a WEND for each WHILE. Example:
C = 1 W H I L EC < 1 0 P R I N TC C = C + 1 W E N D . . . 'T h i si st h es a m ew i t ht h a t
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 25/89

1/15/13

SmallBASIC Guide:

F O RC = 1T O9 P R I N TC N E X T

Statement: REPEAT ... UNTIL expr Begins the definition of a REPEAT/UNTIL loop.

〈 expr〉
An expression BASIC starts executing the commands between the REPEAT and UNTIL commands. When BASIC encounters the UNTIL command, it evaluates the expression parameter. If that parameter is zero (false), the process will be repeated; otherwise, execution continues at the next command. REPEAT/UNTIL loops may be nested to any level of complexity, but there must be an UNTIL for each REPEAT. Example:
C = 1 R E P E A T P R I N TC C = C + 1 U N T I LC = 1 0 . . . 'T h i si st h es a m ew i t ht h a t F O RC = 1T O9 P R I N TC N E X T

Statement: IF ... Syntax:
I Fe x p r e s s i o n 1[ T H E N ] . .[ c o m m a n d s ] . [[ E L S E I F|E L I F ]e x p r e s s i o n 2[ T H E N ] . .[ c o m m a n d s ] . ] [ E L S E . .[ c o m m a n d s ] . ] {E N D I F|F I}

Block-style IF. Causes BASIC to make a decision based on the value of an expression.

〈 expression〉
An expression; 0 is equivalent to FALSE, while all other values are equivalent to TRUE. 〈 commands〉 One or more commands. Each expression in the IF/ELSEIF construct is tested in order. As soon as an expression is found to be TRUE, then its corresponding commands are executed. If no expressions are TRUE, then the commands following the ELSE keyword are executed. If ELSE is not specified, then execution continues with the command following the ENDIF.
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 26/89

1/15/13

SmallBASIC Guide:

IF, ELSE, ELSEIF, and ENDIF must all be the first keywords on their respective lines. THEN is optional, but if its defined it must be the last keyword on its line; if anything other than a comment follows on the same line with THEN, BASIC thinks it's reading a single-line IF/THEN/ELSE construct. IF blocks may be nested. Example:
x = 1 I Fx = 1T H E N P R I N T" t r u e " E L S E P R I N T" f a l s e " E N D I F . . . 'A l t e r n a t es y n t a x : x = 1 I Fx = 1 P R I N T" t r u e " E L S E P R I N T" f a l s e " F I

Single-line IF. Syntax:
I Fe x p r e s s i o nT H E N[ n u m l a b e l ] | [ c o m m a n d ][ E L S E[ n u m l a b e l ] | [ c o m m a n d ] ]

Causes BASIC to make a decision based on the value of an expression.

〈 expression〉 〈 command〉
An expression; 0 is equivalent to FALSE, while all other values are equivalent to TRUE. Any legal command or a numeric label. If a number is specified, it is equivalent to a GOTO command with the specified numeric-label. Example:
'S i n g l e l i n eI F x = 1 I Fx = 1T H E NP R I N T" t r u e "E L S EP R I N T" f a l s e " . . . I Fx = 1T H E N1 0 0 0 . . . 1 0 0 0P R I N T" t r u e "

Function: IF (expression, true-value, false-value) Returns a value based on the value of an expression. Example:
x = 0 P R I N TI F ( x < > 0 , " t r u e " , " f a l s e " ):R E Mp r i n t sf a l s e

Statement: END [error] Statement: STOP [error] Terminates execution of a program, closes all files opened by the program, and returns
w ired_gr.users.sourceforge.net/doc/sb9/guide.html#SEC44 27/89

.1/15/13 SmallBASIC Guide: control to the operating system. for subsequent access via READ command. D A T A" a . Statement: RESTORE label Specifies the position of the next data to be read...html#SEC44 28/89 . . if its not specified the BASIC will return 0. DOS/Windows The 'error' value is very well known as ERRORLEVEL value.6 Statement: DATA constant1 [. BASIC moves to the next DATA item with each READ assignment. w ired_gr. Example: F O Rc = 1T O6 R E A Dx P R I N Tx N E X T . The 〈error〉 is the value which will returned to operating system. . var]] 〈 var〉 Any variable. L A B E LM y D a t a B l o c k D A T A1 . Unless a RESTORE command is executed. . an run-time error occurs. 〈 var〉 Any variable.. If BASIC runs out of DATA items to READ. Command: READ var[. of any type. Example: R E S T O R EM y D a t a B l o c k F O RI = 1T O3 R E A Dv P R I N Tv N E X T E N D . 3 Statement: ERASE var[. .constant2].. All the items supplied by all the DATA commands in a program make up one continuous "string" of information that is accessed in order by your program's READ commands.net/doc/sb9/guide. var . 2 . DATA commands are nonexecutable statements that supply a stream of data constants for use by READ commands. c " .users. 〈 label 〉 A valid label. Stores one or more constants.. b . var[. 〈 error〉 A numeric expression.4 D A T A" f i f t h " .2 D A T A3 .sourceforge.] Assigns values in DATA items to specified variables..

Returns true if the x is a number (or it can be converted to a number) Example: ?I S N U M B E R ( 1 2 ) ?I S N U M B E R ( " 1 2 " ) ?I S N U M B E R ( " 1 2 E + 2 " ) ?I S N U M B E R ( " a b c " ) ?I S N U M B E R ( " 1 + 2 " ) ?I S N U M B E R ( " i n t ( 2 . If x is an integer or a real returns true if the x = 0. If x is an array. Returns true if the x is an array. or a subprogram. P R I N TF R E ( 0 ) E R A S Ex P R I N TF R E ( 0 ) P R I N Tx ( 1 ) : R E ME R R O R Statement: EXIT [FOR|LOOP|SUB|FUNC] Exits a multiline function definition. 〈 FOR〉 Exit from the last FOR-NEXT loop 〈 LOOP〉 Exit from the last WHILE-WEND or REPEAT-UNTIL loop 〈 SUB〉 Return from the current routine 〈 FUNC〉 Return from the current function Function: LEN (x) 〈 x〉 Any variable. a loop. returns the length of the STR(x). After that these variables turned to simple integers with zero value. . returns true if x is a zero-length array (array without elements). for-loop or routine). Function: EMPTY (x) 〈 x〉 Any variable.users. Function: ISNUMBER (x) 〈 x〉 Any variable. returns the number of the elements. By default (if no parameter is specified) exits from last command block (loop.sourceforge. .html#SEC44 : R E Mt r u e : R E Mt r u e : R E Mt r u e : R E Mf a l s e : R E Mf a l s e : R E Mf a l s e 29/89 . returns true if the len(x) is 0. returns the length of the string.net/doc/sb9/guide. If x is an array.1/15/13 SmallBASIC Guide: Deallocates the memory used by the specified arrays or variables. If x is an number. Example: D I Mx ( 1 0 0 ) . Function: ISARRAY (x) 〈 x〉 Any variable. 4 ) " ) w ired_gr. If x is a string. If x is a string.

.. val [. Position in the array. Position in the array. val [. idx. val [. 〈 count 〉 The number of the elements to be deleted..]] 〈 a〉 〈 val 〉 An array-variable. Any value or expression Inserts the values at the end of the specified array. idx [. val [. System Function: FRE (x) Returns system information Where x: QB-standard: 0 free memory -1 largest block of integers . Deletes 'count' elements at position 'idx' of array A 5.. Any value or expression.Function: ISSTRING (x) 〈 x〉 Any variable.]]] 〈 a〉 〈 idx〉 〈 val 〉 An array-variable. . Inserts the values to the specified array at the position idx. Returns true if the x is a string (and cannot be converted to a number) Example: ?I S S T R I N G ( 1 2 ) : R E Mf a l s e ?I S S T R I N G ( " 1 2 " ) : R E Mf a l s e ?I S S T R I N G ( " 1 2 E + 2 " ): R E Mf a l s e ?I S S T R I N G ( " a b c " ) : R E Mt r u e ?I S S T R I N G ( " 1 + 2 " ) : R E Mt r u e Command: APPEND a. Command: INSERT a. Command: DELETE a. count] 〈 a〉 〈 idx〉 An array-variable. .

2 0 0 1 ) Command: DATEDMY dmy | julian_date..m. (dates must be greater than 1/1/100 AD) Example: P R I N TJ u l i a n ( D A T E ) P R I N TJ u l i a n ( 3 1 .-2 free stack -3 largest free block Our standard (it is optional for now): -10 total physical memory -11 used physical memory -12 free physical memory Optional-set #1: -13 shared memory size -14 buffers -15 cached -16 total virtual memory size -17 used virtual memory -18 free virtual memory Optional-set #2: -40 battery voltage * 1000 -41 battery percent -42 critical voltage value (*1000) -43 warning voltage value (*1000) The optional values will returns 0 if are not supported.1 2 . minutes and seconds integer values Function: DATE Returns the current day as string "DD/MM/YYYY" Function: JULIAN (dmy | (d.]] Creates a Run-Time-Error. BYREF s Converts a time-value to hours.. BYREF y Returns the day. Function: TICKS Returns the system-ticks. . BYREF m. BYREF d.y)) Returns the Julian date. Command: RTE [info [. The tick value is depended on operating system. Function: TICKSPERSEC Returns the number of ticks per second Function: TIMER Returns the number of seconds from midnight Function: TIME Returns the current time as string "HH:MM:SS" Command: TIMEHMS hms | timer. . The parameters will be displayed on error-line. BYREF h. BYREF m. month and the year as integers.

It must return 0 if x = y.m m / y y " . The cmpfunc (if its specified) it takes 2 vars to compare. +1 if x > y. y ) Command: SEARCH A. non-zero if x .Function: WEEKDAY (dmy | (d. y ) I Fx = y q s c m p = 0 E L I Fx > y q s c m p = 1 E L S E q s c m p = 1 E N D I F E N D . key.y) | julian_date) Returns the day of the week (0 = Sunday) P R I N TW e e k D a y ( D A T E ) P R I N TW e e k D a y ( J u l i a n ( 3 1 .y) | julian_date) Returns formated date string Format: D one or two digits of Day DD DDD M MM 2-digit day 3-char day name 1 or 2 digits of month 2-digit month DDDD full day name MMM 3-char month name MMMM full month name YY 2-digit year (2K) YYYY 4-digit year P R I N TD A T E F M T ( " d d dd d .1 1 / 0 1 " Command: DELAY ms Delay for a specified amount of milliseconds.1 2 .2 0 0 1 ) ) P R I N TW e e k D a y ( 3 1 .m. If key is not found the SEARCH command returns (in ridx) the value (LBOUND(A)-1). dmy | (d. Command: SORT array [USE cmpfunc] Sorts an array. D I MA ( 5 ) F O Ri = 0T O5 A ( i ) = R N D N E X T S O R TAU S Eq s c m p ( x . cmpfunc must returns -1 if x < y. . 0 if x = y F U N Cq s c m p ( x .m. The cmpfunc (if its specified) it takes 2 vars to compare. In default-base arrays that means -1. .2 0 0 1 ) Function: DATEFMT (format.1 2 . BYREF ridx [USE cmpfunc] Scans an array for the key. This 'delay' is also depended to system clock." 2 3 / 1 1 / 2 0 0 1 " ) R E Mp r i n t s" F r i2 3 .

The file must be a SmallBASIC source code file. the new variable is added. control is returned to the line w ired_gr. Command: RUN cmdstr Loads a secondary copy of system's shell and. or an shell command. y ) c m p = ! ( x = y ) E N D .net/doc/sb9/guide. its current setting is replaced with the new setting.4 . PalmOS SB emulates environment variables. 〈 expr〉 A string expression of the form "name=parameter" If name already exists in the environment table.<> y F U N Cc m p ( x . file . If the parameter is empty ("") then returns an array of the envirment variables (in var=value form) 〈 var〉 A string expression of the form "var" PalmOS SB emulates environment variables.html#SEC44 33/89 .users.A string expression that follows OS file naming conventions.sourceforge.rU S Ec m p ( x . D I MA ( 5 ) F O Ri = 0T O5 A ( i ) = 5 i N E X T S E A R C HA . . Function: ENV ("var") Function: ENVIRON ("var") Returns the value of a specified entry in the current environment table. If name does not exist. . y ) P R I N Tr : R E Mp r i n t s1 P R I N TA ( r ) :R E Mp r i n t s4 Command: CHAIN file Transfers control to another SmallBASIC program. executes an program. EXEC never returns Command: ENVIRON "expr" Command: ENV "expr" Adds a variable to or deletes a variable from the current environment variable-table. 〈 cmdstr〉 Shell's specific command string After the specified shell command or program terminates. B A S " Command: EXEC file Transfers control to another program This routine works like CHAIN with the exception the file can be any executable file. C H A I N" P R O G 2 .

html#SEC44 34/89 . Command: BCOPY src_addr. PalmOS The 'cmdstr' is the Creator-ID. When trace mechanism is ON. PalmOS The RUN never returns. Function: MALLOC (size) Function: BALLOC (size) Allocates a memory block. length Copies a specified portion of memory to a specified file. address. Command: STKDUMP Displays the SB's internal executor's stack w ired_gr.1/15/13 following the RUN command. * The variable can be freed by using ERASE. word or dword at a specified memory address.. word or dword at a specified memory address. Function: RUN ("command") RUN() is the function version of the RUN command. f=( v o i d( * ) ( v o i d ) )a d d r . Function: VADR (var) Returns the memory address of the variable's data. the RUN() returns a string with the output of the 'command' as an array of strings (each text-line is one element). PalmOS The RUN() does not supported. f ( ) .users. address] Loads a specified memory image file into memory. The syntax is the same with the PRINT command. Command: USRCALL addr Transfers control to an assembly language subroutine.. Command: TRON Command: TROFF TRACE ON/OFF. Command: BSAVE filename. value Writes a specified byte.net/doc/sb9/guide. PRINT to SB's logfile. dst_addr. length Copies a memory block from 'src_addr' to 'dst_addr' Command: BLOAD filename[. The difference is that. Windows The stdout and stderr are separated! First is the stdout output and following the stderr. The USRCALL is equal to: v o i d( * f ) ( v o i d ) .sourceforge. Function: PEEK[{16|32}] (addr) Returns the byte. Command: POKE[{16|32}] addr. the SB displays each line number as the program is executed Command: LOGPRINT .

8 = dark-gray. full 24-bit RGB colors can be passed by using negative number. 2D algebra commands are working with reals) That is different of QB. 6.sourceforge. 16 colors of gray (on PalmOS) 8bit (256 paletted colors) 16 Standard VGA colors.y 1 . 1-6.3 The STEP keyword The STEP keyword calculates the next x.. 15 = white. The rest colors are ignored. 15 = white 2bit (4 colors) 0 = black.4 The 'aspect' parameter w ired_gr.users.1/15/13 SmallBASIC Guide: * For debug purposes. but its much faster.7M colors) Color 0. the polylines can work with the same way. 6. .html#SEC44 .y 2 o r L I N E[ x 1 .x 2 . 7. That position can be returned by using the POINT(0) and POINT(1) functions. 6.net/doc/sb9/guide. Graphics & Sound The SB's Graphics commands are working only with integers. 9-14 = light-gray 4bit (16 colors) 16 Standard VGA colors.15 is the standard VGA colors. 6.y 2 ] Also. 15bit (32K colors). . 16bit (64K colors) and 24bit (1.1 The colors Monochrome 0 = black.y ] 6.2 The points Any point can be specified by an array of 2 elements or by 2 parameters Example: L I N Ex 1 .y 1 ] . p o l y [ 0 ]=[ x . (Of course. D I Mp o l y ( 1 0 ) . it is not supported on "limited" OSes.[ x 2 .y parameters relative to current position.

w ired_gr.aspect [. Command: COLOR foreground-color [. then even elements for x (starting from 0). scalef [.6 Graphics Commands Command: ARC [STEP] x. type [.astart. xmax USE f(x) Graph of f(x) Example: P L O T0 . color]] [COLOR color] [FILLED] 〈 x〉 〈 y〉 〈 r〉 the circle's center the radius Draws a circle (or an ellipse if the aspect is specified). x1. array() [. The number of pixels moved is equal to n multiplied by the current scaling factor. n specifies a distance to move.x2.color]] [COLOR color] Draws an arc.y1.sourceforge. string . x2. y1.y-origin [. Graphics Definition Language In the movement instructions below.y.html#SEC44 36/89 .5 The FILLED keyword The FILLED keyword fills the result of the command with the drawing color.A string expression containing commands in the BASIC graphics definition language. y2]] Draws a chart of array values in the rectangular area x1. 6. background-color] Specifies the foreground and background colors Command: DRAWPOLY array [. astart.1/15/13 SmallBASIC Guide: The x/y factor.y.r [. which is set by the S command.aspect [.net/doc/sb9/guide.last angle in radians.r. 6.aend = first.users. odd elements for y Command: DRAW string Draws an object according to instructions specified as a string. color]]] [COLOR color] [FILLED] Draws a polyline If the array does not uses points as element arrays.y2 Where 'type': 0 simple 1 with marks 2 with ruler 3 with marks & ruler Command: PLOT xmin.x-origin. Command: CHART {LINECHART|BARCHART}.2 * P IU S ES I N ( x ) Command: CIRCLE [STEP] x.aend [.

row) within the area that is to be filled. Next movement command moves but doesn't plot. * This command it is had not tested . Move diagonally down and left.users. which is set by the S command. Un Dn Ln Rn En Fn Gn Hn Mx. Next movement command moves.|STEP} x2. If x is preceded by a + or -.sourceforge. A prefix command. 〈 x〉 〈 y〉 Screen coordinate (column.color [. y]) Returns the color of the pixel at x. A prefix command. y [. Function: POINT (x [. color | COLOR color] Draws a line Command: PSET [STEP] x. the movement is relative to the last point referenced.border]] Fills an enclosed area on the graphics screen with a specific color. Move right.y B N Move up. color | COLOR color] [FILLED] Draws a rectangular parallelogram Function: TXTW (s) Function: TEXTWIDTH (s) Returns the text width of string s in pixels Function: TXTH (s) Function: TEXTHEIGHT (s) Returns the text height of string s in pixels Function: XPOS Function: YPOS Returns the current position of the cursor in "characters".y2] [. Move to coordinate x. Move diagonally up and left.y2] [.y [{.y if y does not specified x contains the info-code 0 = returns the current X graphics position 1 = returns the current Y graphics position Command: PAINT [STEP] x.y [.|STEP} x2.please report any bug or incompatibility.net/doc/sb9/guide.y [{. but returns immediately to previous point.y.html#SEC44 37/89 . 〈 color〉 The fill-color 〈 border〉 The boundary-color w ired_gr. Move diagonally up and right. Move diagonally down and right. color | COLOR color] Draw a pixel Command: RECT [STEP] x. Command: LINE [STEP] x. Move left.1/15/13 SmallBASIC Guide: moved is equal to n multiplied by the current scaling factor. Move down.

users.1/15/13 SmallBASIC Guide: if the border-color is specified then the PAINT will fill all the area which is specified by the border-color..y2 [. g.y) if the border-color is NOT specified then the PAINT will fill all the are with the same color as the pixel at x. 〈 color〉 If included. b) The RGBF functions returns the RGB color codes for the specified values The RGBF() takes values 0. Command: WINDOW [x1. is multiplier 1. 〈 border-color〉 If included. . The WINDOW command allows you to redefine the corners of the display screen as a pair of "world" coordinates.html#SEC44 38/89 .5 O n Octave 0. Command: BEEP Generates a beep sound Command: PLAY string Play musical notes A G [ | + | # ] [ n n n ] [ . (fill-until.y1. The viewport defined by VIEW is disabled by a VIEW command with no parameters.84 (0 = pause) P n n n Pause 1. 〈 x1〉 〈 y1〉 〈 x2〉 〈 y2〉 Corner coordinates of the viewport. BASIC draws a border.. (fill-while.y)) Command: VIEW [x1. . +|# is sharp. around the defined viewport...color [.6.255 for each of the color.border-color]]] Defines a viewport.x2. 〈 x1〉 〈 y1〉 〈 x2〉 〈 y2〉 The corner coordinates of the world space. < moves down one octave.x2. Function: RGB (r. The return value is a negative 24bit value to by used by drawing functions.G. in a specified color. g. BASIC fills the viewport with the specified color. The world space defined by WINDOW is disabled by a WINDOW command with no parameters. Function: RGBF (r.net/doc/sb9/guide. b) The RGB functions returns the RGB color codes for the specified values The RGB() takes values 0.1 for each of the color.y1.sourceforge. ] Play note A.. > moves up one octave N n n Play note 0.y2] Specifies "world" coordinates for the screen. The return value is a negative 24bit value to by used by drawing functions. color!=point(x.64 w ired_gr. color=point(x..is flat.y.

dim]) Returns the lower bound of the 'array' The parameter 'dim' is the array dimension whose bound is returned D I Mv 1 ( 4T O7 ) D I Mv 2 ( 1T O2 ..net/doc/sb9/guide. dur_ms [. M S Staccato (1/2) M N Normal (3/4) M L Legato V n n n Volume 0.3T O4 ) . dim]) Returns the upper bound of the 'array' Function: LBOUND (array [.html#SEC44 39/89 . Number of 1/4 notes per minute.64 (1/nnn) T n n n Tempo 32.255.. . P R I N TL B O U N D ( v 1 ) :R E M4 P R I N TU B O U N D ( v 1 ) :R E M7 .. vol] [BG] Plays a sound 〈 freq〉 〈 dur_ms〉 〈 vol 〉 〈 BG〉 The frequency The duration in milliseconds The volume in 1/100 units Play it in background Command: NOSOUND Stops background sound. 2 ):R E M3 w ired_gr.L n n n Length of note 1.sourceforge. Miscellaneous Command: RANDOMIZE [int] Seeds the random number generator Function: RND Returns a random number from the range 0 to 1 Function: UBOUND (array [. P R I N TL B O U N D ( v 2 ) :R E M1 P R I N TL B O U N D ( v 2 . 7. Also.100 M F Play on foreground M B Play on background Q Clear sound queue Command: SOUND freq. . clears the sound queue.users. . .

or until user hit the keyboard. Meaningless.14) Returns the PEN/MOUSE data. Command: SWAP a. MOUSE: mouse left button is pressed PEN: last/current x. Used for compatibility. Used for compatibility.. b Exchanges the values of two variables.Function: CINT (x) Converts x to 32b integer Meaningless. Function: CDBL (x) Convert x to 64b real number. 8. Meaningless. The parameters may be variables of any type. Function: PEN (0. File system . Used for compatibility. Function: CREAL (x) Convert x to 64b real number. MOUSE: the current x position only if the left mouse button is pressed (like PEN is down) Same as PEN(4) for y Mouse specific (non PalmOS): 〈 10〉 〈 11〉 〈 12〉 〈 13〉 〈 14〉 current mouse x pos current mouse y pos true if the left mouse button is pressed true if the right mouse button is pressed true if the middle mouse button is pressed * The driver must be enabled before use this function (see Pen command) Command: PAUSE [secs] Pauses the execution for a specified length of time. MOUSE: last mouse button down x Same as 1 for y true if the PEN is down. Command: PEN ON|OFF Enables/Disables the PEN/MOUSE mechanism. Values: 〈 0〉 〈 1〉 〈 2〉 〈 3〉 〈 4〉 〈 5〉 true (non zero) if there is a new pen or mouse event PEN: last pen down x.

net/doc/sb9/guide. 〈 file〉 A string expression that follows OS file naming conventions. " M M C : f i l e n a m e " eBookMan only. 1 = load into string Command: TSAVE file. beginning at current EOF The files are always opened as shared.html#SEC44 41/89 . w ired_gr.1 Special Device Names " C O M 1 : [ s p e e d ] " Serial port 1 " C O M 2 : [ s p e e d ] " Serial port 2 " P D O C : f i l e n a m e " Compressed PDOC files for PalmOS or PDB/PDOC files on other systems. and compress the file on CLOSE. Memo records (virtual files) are limited to 3935 bytes " S O C L : s e r v e r : p o r t " Socket client. Each array element is a text-line.users. Opens an MMC file.1/15/13 SmallBASIC Guide: 8. Any variable 0 = load into array (default).sourceforge. " M E M O : m e m o t i t l e " MemoDB of PalmOS or regular file on other systems. PDOCFS opens and uncompress the file on OPEN. sequential output. So. 〈 fileN〉 A file-handle (integer 1 to 256). Example: OPEN "COM1:" AS #1 OPEN "COM2:38400" AS #2 8. BYREF var [. Command: CLOSE #fileN Close a file or device Command: TLOAD file. 〈 FOR -〉 INPUT Sequential input OUTPUT Sequential output APPEND Sequential output. type] Loads a text file into array variable. 〈 file〉 〈 var〉 〈 type〉 A string expression that follows OS file naming conventions. Each text-line is an array element. var Writes an array to a text file.2 File System Commands Function: FREEFILE Returns an unused file handle Command: OPEN file [FOR {INPUT|OUTPUT|APPEND}] AS #fileN Makes a file or device available for sequential input. Actually a telnet client. it will use a lot of memory and time (its depended on size of the data).

An array variable or a string variable.users. Function: ACCESS (file) Returns the access rights of the file. DOS The return value is depended on DJGPP's stat() function. The return-value is the permissions of the file as them as specified on GNU's manual (chmod() and stat() system calls) The bits (in octal): 04000 set user ID on execution 02000 set group ID on execution 01000 sticky bit 00400 read by owner 00200 write by owner 00100 execute/search by owner 00040 read by group 00020 write by group 00010 execute/search by group 00004 read by others 00002 write by others 00001 execute/search by others PalmOS The return value is always 0777. Function: ISDIR (file) Returns true if the 〈file〉 is a directory.net/doc/sb9/guide. I FA C C E S S ( " / b i n / s h " )A N D0 o 4T H E N P R I N T" Ic a nr e a di t ! " E N D I F Function: ISFILE (file) Returns true if the 〈file〉 is a regular file. Expressions are not allowed for memory reasons.sourceforge. Windows The return value is depended on Cygnus's stat() function. Possible Unix compatible.1/15/13 SmallBASIC Guide: 〈 file〉 〈 var〉 A string expression that follows OS file naming conventions. Possible Unix compatible. Function: ISLINK (file) Returns true if the 〈file〉 is a link. mode Change permissions of a file w ired_gr. Function: EXIST (file) Returns true if the file exists 〈 file〉 A string expression that follows OS file naming conventions.html#SEC44 42/89 . Command: CHMOD file. 〈 file〉 A string expression that follows OS file naming conventions.

The common problem with INPUT/PRINT set is there are many conflicts with data. Command: KILL "file" Deletes the specified file Command: WRITE# fileN.}] var Reads a whole text line from file or console.|. var1 [. The syntax is the same with the PRINT command. pos Sets file position for the next read/write Function: SEEK (fileN) Returns the current file position Function: LOF (fileN) Returns the length of file in bytes. fileN]) This function is similar to INPUT.. . 'M a k em y f i l ea v a i l a b l et oa n y o n e( r e a d / w r i t e ) C H M O D" m y f i l e . * We can use 'USG' instead of 'USING'. . That means does not convert the data. The mode is compatible with the chmod()'s 'mode' parameter as its described on GNU's manual.w o r l d " 43/89 . it returns the number of available data." H e l l o . See ACCESS() for more information...delim]] . Command: PRINT# fileN. var1 [.0 o 6 6 6 . Command: INPUT# fileN.. and does not remove the spaces. Reads data from file Function: BGETC (fileN) (Binary mode) Reads and returns a byte from file or device.] Command: READ# fileN. var1 [. For COMx and SOCL VFS it returns true if the connection is broken.|..delim] [. var2 [. [USING..] The READ/WRITE command set is used to store variables to a file as binary data. Command: BPUTC# fileN. .}] var Command: LINE INPUT# [fileN{...] .|. Function: INPUT (len [.1/15/13 SmallBASIC Guide: 〈 file〉 〈 mode〉 A string expression that follows OS file naming conventions. P R I N T# 1 .}] var Command: LINEINPUT# [#fileN{.. Command: LINPUT# [fileN{.0 o 7 7 7 Function: EOF (fileN) Returns true if the file pointer is at end of the file. . 'M a k em y f i l ea v a i l a b l et oa n y o n e( e x e c u t e / r e a d / w r i t e ) C H M O D" m y f i l e . b a s " .. b a s " . For other devices. This function is a low-level function. Reads 'len' bytes from file or console (if fileN is omitted). byte (Binary mode) Writes a byte on file or device Command: SEEK# fileN. Write string to a file.

but this is impossible for INPUT command to understand it. "U S EP R N F ( x ) PalmOS Not supported. This does not working on PalmOS. .html#SEC44 44/89 . Command: CHDIR dir Changes the current working directory. This does not working on PalmOS. Command: COPY "file". . Function: FILES (wildcards) Returns an array with the filenames. you can store arrays. "newname" Renames the specified file Command: MKDIR dir Create a directory.1/15/13 SmallBASIC Guide: You have wrote only one string and you want read it in one variable. The user-defined function must returns zero to stop the process. strings etc and what is you write is what you will read the next time.. * Its very bad idea to mixed READ/WRITE commands with INPUT/PRINT commands in the same file. wildcards] [USE . so it thinks there are two variables not one. BTW its faster too. F U N CP R N F ( x ) ?x P R N F = T R U E E N D . Command: RMDIR dir Removes a directory. now. So.] Walk through the directories. "newfile" Makes a copy of specified file to the 'newfile' Command: RENAME "file".sourceforge. ?F I L E S ( " * " ) PalmOS Returns only the user-files. Command: DIRWALK directory [.net/doc/sb9/guide.. * To use file on MEMO or PDOC or any other virtual file system you must use FILES("VFSx:*") P R I N TF I L E S ( " M E M O : * " ) w ired_gr. * The parameters can be variables ONLY. This does not working on PalmOS. D I R W A L K" . because INPUT finds the separator comma. If there is no files returns an empty array.users.

users. Parameters can be anything (arrays. 1 1 ) Command: EXPRSEQ BYREF array.1/15/13 SmallBASIC Guide: 9. 1 .sourceforge.) Function: ABSMIN (. 1 1 ) E X P R S E Qv . ints. 1 .1 1U S Ex Function: POW (x. 3 ) ?M A X ( " a b c " . ?S E Q ( 0 . strings). ?M A X ( 3 . y) x raised to power of y Function: SQR (x) Square root of x Function: SGN (x) Sign of x (+1 for positive. xmax. R E Ms a m ea sv = S E Q ( 0 . Mathematics All angles are in radians.2 Round w ired_gr.net/doc/sb9/guide.. xmin..html#SEC44 45/89 . " d e f " ) Function: SEQ (xmin.. Function: MAX (.) Function: ABSMAX (.1 Unit convertion Function: DEG (x) Radians to degrees Function: RAD (x) Degrees to radians 9. -1 for negative and 0 for zero) 9... count) Returns an array with 'count' elements. 4 ... xmax. reals.1 .0 . count USE expression Returns an array with 'count' elements.) Function: MIN (. ABSMIN/ABSMAX returns the absolute min/max value. Each element had the 'y' value of its position as it is returned by the expression. 8 ) ?M I N ( a r r a y ( ) .) Maximum/Minimum value of parameters.. Each element had the x value of its position. Function: ABS (x) Returns the absolute value of 〈x 〉. 2 .

3 Trigonometry Function: COS (x) Cosine Function: SIN (x) Sine Function: TAN (x) Tangent Function: ACOS (x) Inverse cosine Function: ASIN (x) Inverse sine Function: ATAN (x) Function: ATN (x) Inverse tangent Function: ATAN2 (x. 9. decs]) Rounds the x to the nearest integer or number with 'decs' decimal digits.net/doc/sb9/guide.html#SEC44 46/89 .sourceforge.users. y) Inverse tangent (x.y) Function: COSH (x) Function: SINH (x) Function: TANH (x) Function: ACOSH (x) Function: ASINH (x) Function: ATANH (x) Function: SEC (x) Secant Function: CSC (x) Cosecant w ired_gr.1/15/13 SmallBASIC Guide: Function: INT (x) Rounds x downwards to the nearest integer Function: FIX (x) Rounds x upwards to the nearest integer Function: FLOOR (x) Largest integer value not greater than x Function: CEIL (x) Smallest integral value not less than x Function: FRAC (x) Fractional part of x Function: ROUND (x [.

. 9. Function: LOG (x) Returns the natural logarithm of 〈x 〉. Function: LOG10 (x) Returns the base-10 logarithm of 〈x 〉.4 Logarithms Function: EXP (x) Returns the value of e raised to the power of 〈x 〉.) Sample spread Function: STATSPREADP (..html#SEC44 ..net/doc/sb9/guide..users..) w ired_gr..5 Statistics Sample standard deviation: SQR(STATSPREADS(array)) Population standard deviation: SQR(STATSPREADP(array)) Function: SUM (.) Sum of square value Function: STATMEAN (.) Arithmetical mean Function: STATMEANDEV (.sourceforge..1/15/13 SmallBASIC Guide: Function: COT (x) Cotangent Function: ASEC (x) Inverse secant Function: ACSC (x) Inverse cosecant Function: ACOT (x) Inverse cotangent Function: SECH (x) Function: CSCH (x) Function: COTH (x) Function: ASECH (x) Function: ACSCH (x) Function: ACOTH (x) 9.....) Sum of value Function: SUMSQ (.) Mean deviation Function: STATSPREADS (..

6 Equations Function: LINEQN (a.5 0 0 .e r r c o d eU S EF ( x ) Command: DERIV x. maxerr. This function solves equations by using the Gauss-Jordan method.. BYREF result. b [.5 . (the absolute value of the lowest acceptable number) default = 0 = none.html#SEC44 .net/doc/sb9/guide. BYREF errcode USE expr Calculation of derivative w ired_gr. high.0 . |x| <= toler : x = 0 * The result is a matrix Nx1.sourceforge.. Function: DETERM (A[. For the SB that array is two-dimension array.r e s u l t . . toler]) Determinant of A toler = tolerance number (the absolute value of the lowest acceptable number) default = 0 = none |x| <= toler : x = 0 Command: ROOT low. BYREF errcode USE expr Roots of F(x) 〈 toler〉 〈 low〉 〈 high〉 〈 segs〉 the lower limit the upper limit the number of segments (spaces) 〈 maxerr〉 tolerance (IF ABS(F(x)) < maxerr THEN OK) 〈 errcode〉 0 for success. segs. 0 0 0 0 1 . . maxerr. BYREF result. 〈 b〉 〈 b〉 equations results tolerance number. R O O T1 . maxtries.1/15/13 SmallBASIC Guide: Population spread 9. toler]) Returns an array with the values of the unknowns. Function: INVERSE (A) returns the inverse matrix of 〈A〉.users. otherwise calculation error 〈 result 〉 the result F U N CF ( x ) F=S I N ( x ) E N D .

Dy) Sinus or cosine of 2 line segments (A->B.sourceforge.Dy) Function: SEGSIN (Ax. maxerr.Bx.Cy.Ay. Bx. BYREF ymax Returns the polyline's extents Command: INTERSECT Ax.By.Ay. Command: POLYEXT poly().Bx. Function: PTDISTSEG (Bx.Ry = cross w ired_gr.html#SEC44 49/89 . By.Cy.Cx.By.By) Length of line segment Function: POLYAREA (poly) Returns the area of the polyline 〈poly〉. BYREF ymin. BYREF errcode USE expr Differential equation .By.Cy.Ax. C->D).Ay) Distance of point A from line segment B-C Function: PTDISTLN (Bx. BYREF xmin. xf.y x final 〈 maxseg〉 maximum number of segments on x 〈 maxerr〉 tolerance (acceptable error between the last 2 times) 〈 errcode〉 0 for success.Cx.By.Dx.Bx.users. BYREF yf. 2D Algebra Function: SEGCOS (Ax.Dx. y0.Ay) Distance of point A from line B.Ay.Cx. maxseg.1/15/13 SmallBASIC Guide: 〈 x〉 〈 maxtries〉 〈 maxerr〉 value of x maximum number of retries tolerance 〈 errcode〉 0 for success.By.Cx. BYREF xmax.Qx.Qy) The sign of point Q from line segment A->B Function: SEGLEN (Ax.net/doc/sb9/guide.Ax. Ay. Cx. Dx.Ay. C Function: PTSIGN (Ax. otherwise calculation error 〈 yf〉 the result 10. BYREF type.Runge-Kutta method 〈 x0〉 〈 y0〉 〈 xf〉 initial x. otherwise calculation error 〈 result 〉 the result Command: DIFFEQN x0. BYREF Ry Calculates the intersection of the two line segments A-B and C-D Returns: Rx.Bx. BYREF Rx. Dy. Cy.Cy.

x.1 2D & 3D graphics transformations 2D & 3D graphics transformations can represented as matrices. s=sinè) Command: M3IDENT BYREF m3x3 Resets matrix (Identity) | 1 0 0| | 0 1 0| | 0 0 1| Command: M3ROTATE BYREF m3x3. y. angle [. Ty Translation | 1 0 0| | 0 1 0| |T xT y 1| Command: M3APPLY m3x3.net/doc/sb9/guide. Tx. (c=cosè.1/15/13 SmallBASIC Guide: type = cross-type 0 No cross (R = external cross) 1 One cross 2 Parallel 3 Parallel (many crosses) 4 The cross is one of the line segments edges. y] Rotate by angle with center x. 10. x.sourceforge.html#SEC44 50/89 . Sy Scaling |S x 0 0| | 0S y 0| | * * 1| Command: M3TRANS BYREF m3x3.users. BYREF poly Apply matrice to poly-line Additional information: | 1 0 0| | 01 0|=r e f l e c t i o no nx | 0 0 1| |1 0 0| | 0 1 0|=r e f l e c t i o no ny | 0 0 1| 3D-Graphics Matrices: w ired_gr. Sx.y | c s 0| |s c 0| | * * 1| Command: M3SCALE BYREF m3x3.

Function: STR (x) w ired_gr.0 .html#SEC44 .p i / 2 . .0 M 3 S C A L EM . 'D r a wt h eo r i g i n a lp o l y l i n e D R A W P O L Yp o l y . M 3 I D E N TM M 3 R O T A T EM .1/15/13 SmallBASIC Guide: | | | | 1 0 0 0 0 1 0 0 0T x| 0T y|=t r a n s l a t i o n 1T z| 0 1| 0| 0|=s c a l i n g 0| 1| 0| 0|=r o t a t i o no nx 0| 1| 0| 0|=r o t a t i o no ny 0| 1| 0| 0|=r o t a t i o no nz 0| 1| |S x 0 0 | 0S y 0 | 0 0S z | 0 0 0 | | | | 1 0 0 0 0 0 cs s c 0 0 0 1 0 0 s 0 c 0 0 0 1 0 | c | 0 |s | 0 | | | | cs s c 0 0 0 0 Any change to matrix will combined with its previous value. Function: VAL (s) Returns the numeric value of string 〈s〉.p o l y D R A W P O L Yp o l y 11.users. Function: OCT (x) Returns the octal value of x as string. 2 ) . . 0a n ds c a l e db y1 .sourceforge. 2 4 M 3 A P P L YM . . 2 4 .1 . . Function: HEX (x) Returns the hexadecimal value of x as string. .0 . . 2 4 . Strings Function: SPC (n) Function: SPACE (n) returns a string of 'n' spaces Function: BIN (x) Returns the binary value of x as string. D I Mp o l y ( 2 4 ) D I MM ( 2 .1 . 'D r a wt h ep o l y l i n e 'r o t a t e db yp i / 2f r o m0 .0 .net/doc/sb9/guide.

ignore-pairs]]) Discloses a string. Function: CBS (s) Function: BCS (s) CBS() . The default pair is "" ?e n c l o s e ( " a b c " . pairs [. pair]) Encloses a string. Function: LOWER (s) Function: LCASE (s) Function: UPPER (s) Function: UCASE (s) Converts the string s to lower/upper case ?L O W E R ( " H i " ) : R E Mh i ?U P P E R ( " H i " ) : R E MH I Function: LTRIM (s) Removes leading white-spaces from string s ?L E N ( L T R I M ( " H i " ) ) : R E M2 Function: RTRIM (s) Removes trailing white-spaces from string s Function: TRIM (s) Removes leading and trailing white-spaces from string 〈s〉.S Q U E E Z E ( "H i t h e r e" ) .html#SEC44 52/89 . Default pairs and ignore pairs w ired_gr.converts (B)ASIC-style strings to (C)-style (S)trings C-Style string means strings with \ codes * On CBS() we cannot use the \" character but we can replace it with \x22 or \042." ] " 'R e s u l t :[ H it h e r e ] Function: ENCLOSE (str[. T R I Mis equal to L T R I M ( R T R I M ( s ) ) Function: SQUEEZE (s) Removes the leading/trailing and duplicated white-spaces ?" [ " . Function: CHR (x) Returns one-char string of character with ASCII code x.net/doc/sb9/guide.users.sourceforge.converts (C)-style strings to (B)ASIC-style (S)trings BCS() . Function: ASC (s) Returns the ASCII code of first character of the string 〈s〉." ( ) " ) 'R e s u l t :( a b c ) Function: DISCLOSE (str[.1/15/13 Returns the string value of 〈x 〉.

Function: LEFTOFLAST (s1." ' ' " ) 'p r i n t sa = ' ( b c ) ' ." ' ' " ) . s2) Returns the left/right part of s1 at the position of the last occurrence of the string s2 into string s1 * s2 does not included on new string. s2) Returns the position of the first occurrence of the string s2 into string s1 (starting from the position 'start') If there is no match.html#SEC44 ." ( ) " .1/15/13 SmallBASIC Guide: F i r s t n o nw h i t e s p a c e c h a r a c t e r C h e c k I g n o r e " " " ' ' ' ' ' " " ( ( ) " " ' ' [ [ ] " " ' ' { { } " " ' ' < < > " " ' ' O t h e r w i s e : " " " ' ' s=" a b c( a b c ) " ?s .] s1.net/doc/sb9/guide.sourceforge.d i s c l o s e ( d i s c l o s e ( s .n]) Returns the n number of leftmost/rightmost chars of string s If n is not specified. the SB uses 1 Function: LEFTOF (s1. INSTR returns 0 Function: RINSTR ([start." ( ) " ) 'p r i n t sa ( b c ) . Function: MID (s.d i s c l o s e ( s .t a b ( 2 6 ) . s2) Returns the position of the last occurrence of the string s2 into string s1 (starting from the position 'start') If there is no match.& d i s c l o s e ( d i s c l o s e ( s . s2) Function: RIGHTOFLAST (s1. start [. s2) Returns the left/right part of s1 at the position of the first occurrence of the string s2 into string s1 * s2 does not included on new string.t a b ( 2 6 ) ." ( ) " ) 'p r i n t sa b c s=" a b c( a ( b c ) ) " ?s . RINSTR returns 0 w ired_gr." ( ) " .t a b ( 4 0 ) .] s1." ' ' " ) .n]) Function: RIGHT (s[.b c s=" a b c( a = ' ( b c ) ' ) " ?s . s2) Function: RIGHTOF (s1.length]) Returns the part (length) of the string s starting from 'start' position If the 'length' parameter is omitted." ( ) " ) .t a b ( 2 6 ) .d i s c l o s e ( s .users.d i s c l o s e ( s . MID returns the whole string from the position 'start'." ( ) " . Function: INSTR ([start.n o t h i n g Function: LEFT (s [." ( ) " ) .t a b ( 4 0 ) .

net/doc/sb9/guide. len]) Writes the 'str' into 'pos' of 'source' and returns the new string. 'I n s e r t ?r e p l a c e ( s . 2 ) Function: TRANSLATE (source. s = " 1 2 3 4 5 6 " . Function: STRING (len. pos." O " ) 'd i s p l a y s :H e l l Ow O r l d Function: CHOP (source) Chops off the last character of the string 'source' and returns the result. Strings: & Stores a string expression without reformatting it. \\ Stores only the first n + 2 characters of a string expression.users. 'C u t ?r e p l a c e ( s . This function replaces only 'len' characters. 'R e p l a c e&i n s e r t ?r e p l a c e ( s . " b c d " ) . - Stores minus if the number is negative. " c d e " . The position of the decimal point. " " . ! Stores only the first character of a string expression." o " . . ?T r a n s l a t e ( " H e l l ow o r l d " . l e n ( s ) ) . + Stores the sign of the number. where n is the number of spaces between the two backslashes.html#SEC44 54/89 . with]) Translates all occurrences of the string 'what' found in the 'source' with the string 'with' and returns the new string. 0 ) . . what [. 2 . Unlike QB. . str [.1/15/13 Function: REPLACE (source. Unlike QB's USING format this is a place-holder like the #. " R R I " . 3 . Numbers: # Digit or space 0 Digit or zero ^ Stores a number in exponential format. there can be literals inside the \ \. w ired_gr. 'R e p l a c e ?r e p l a c e ( s . The default value of 'len' is the length of 'str'. {ascii|str}) Returns a string containing 'len' times of string 'str' or the character 'ascii'. Function: FORMAT (format. 2 . . . . . 3 . . . . val) Returns a formated string.sourceforge. Separator.

Splits the string 'src' into variables which are separated by delimiters. Command: SINPUT src.v d o 'r e s u l ti nm o n i t o r 'x > 1 y Command: SPLIT string." a b c d e " ):R E Mp r i n t s" a b c d e " Command: SPRINT var. v ( i ) .var [. Console w ired_gr. " ] " N E X T ' d i s p l a y s : 0[ ] 1[ e t c ] 2[ t e m p ] 3[ f i l e n a m e ] 4[ e x t ] Command: JOIN words(). words() [. delimiters. # # 0 " .v ( ) J O I Nv ( ) ." / " . e x t " S P L I Ts ." / . "[ " ." t h e n " . Create formated string and storing it to var The syntax is the same with the PRINT command. 2 3 . string Returns the words of the specified string into array 'words' Example: s = " / e t c / t e m p / f i l e n a m e . " . 6 ):R E Mp r i n t s1 .net/doc/sb9/guide.sourceforge. delimiters. * You can use 'USG' instead of 'USING'..v ( ) F O Ri = 0T OU B O U N D ( v ) P R I N Ti . ?F O R M A T ( " # . delim]] . S P R I N Ts .v d o ?v c o n d .1 9 2 0 ."" .s P R I N T" [ " .html#SEC44 55/89 .1 2 . e x t " S P L I Ts .] ..users... " ] " ' d i s p l a y s : [ / e t c / t e m p / f i l e n a m e / e x t ] 12.T A B ( 1 2 ) .v c o n d .. var [." / . s . [USING.v i f .1 1 . 3 4 .. delim] [.1/15/13 SmallBASIC Guide: These literals are inserted in the final string. pairs] [USE expr] Returns the words of the specified string into array 'words' Example: s = " / e t c / t e m p / f i l e n a m e . S I N P U T" i fx > 1t h e ny " . " .. 9 2 1 ?F O R M A T ( " \ -\ " .

1 Supported console codes * \e = CHR(27) \t \a \r\n \xC \e[K tab (32 pixels) beep new line (cr/lf) clear screen clear to EOL \e[nG moves cursor to specified column \e[0m reset all attributes to their defaults \e[1m set bold on \e[4m set underline on \e[7m reverse video \e[21m set bold off \e[24m set underline off \e[27m set reverse off \e[3nm set foreground color.3) select buildin font eBookMan only: \e[50m select 9pt font \e[51m select 12pt font \e[52m select 16pt font \e[nT move to n/80th screen character position 12.html#SEC44 56/89 . (see set foreground) PalmOS only: \e[8nm (n=0.7) select system font \e[9nm (n=0.users.1/15/13 SmallBASIC Guide: 12.2 Console Commands w ired_gr.sourceforge..net/doc/sb9/guide. where n: 0 black 1 red 2 green 3 brown 4 blue 5 magenta 6 cyan 7 white \e[4nm set background color..

sourceforge.|. # # 0 . .] [expr|str [{. . # # 0o f\\ " .net/doc/sb9/guide. SPC(n) Prints a number of spaces specified by n. The combination _#.html#SEC44 57/89 . Calling a PRINT USING without a new format specified the PRINT will use the format of previous call.n u m b e r . [other] literals in the format string..A ( i ) N E X T .} [expr|str]] . . A TAB character is placed." b y t e s " * The symbol ? can be used instead of keyword PRINT You can use 'USG' instead of 'USING'. Carriage return/line feed suppressed after printing. .i + 1 .users. # # # . Unlike the FORMAT. too. _ example. allows you to include a number sign as a literal in your numeric format. Function: CAT (x) Returns a console codes 0 reset 1 bold on -1 bold off 2 underline on -2 underline off 3 reverse on -3 reverse off w ired_gr. for * When a PRINT USING command is executed the format will remains on the memory until a new format is passed. P R I N TU S I N G" T o t a l# # # . Examples: P R I N TU S I N G" # # :# . PRINT SEPARATORS TAB(n) Moves cursor position to the nth column. .. 0 0 " . The PRINT USING Print USING. Displays a text or the value of an expression. is using the FORMAT() to display numbers and strings. this one can include literals. F O Ri = 0T O2 0 P R I N TU S I N G . Carriage return/line feed suppressed after printing. Characters other than the foregoing may be included as Print next character as a literal.1/15/13 SmallBASIC Guide: Command: PRINT [USING [format].

Interactive Mode Like a shell.. Example: k = I N K E Y I FL E N ( k ) I FL E N ( k ) = 2 ?" H / W# " + A S C ( R I G H T ( k . SB can run interactively.87 select system font 90.]] Reads from "keyboard" a text and store it to variable. x Moves the console cursor to the specified position. w ired_gr. var [.}] var[. it is offers a quick editing/testing tool for console mode versions of SB. The Interactive Mode offers an old-style coding taste. " B o l d " . but also. Command: LINPUT var Command: LINEINPUT var Command: LINE INPUT var Reads a whole text line from console. c a t ( 0 ) Command: INPUT [prompt {. A. .y are in pixels Command: LOCATE y. Command: AT x. It executes shell commands as a normal shell.93 select custom font Example: ?c a t ( 1 ) . The Interactive Mode can be used as a normal command-line shell.|. or an empty string if there are no keys.users.net/doc/sb9/guide.A S C ( k ) F I E L S E ?" k e y b o a r db u f f e ri se m p t y " F I Command: CLS Clears the screen."" .sourceforge. it can store/edit and run SB programs... 1 ) ) E L S E ?k . x.html#SEC44 58/89 . x..y are in character cells. Also. Function: INKEY This function returns the last key-code in keyboard buffer. y Moves the console cursor to the specified position. Special key-codes like the function-keys (PC) or the hardware-buttons (PalmOS) are returned as 2-byte string. However we suggest to use an editor. We can use the [TAB] for autocompletion (re-edit program lines or filename completition).1/15/13 SmallBASIC Guide: PalmOS only: 80.

If a number preceeded by a hyphen follows LIST. We can use [ARROWS] for history.[end-line] } The ERA command allows you to erase program lines. There is no need to type line numbers. which can also be used as a statement. If two numbers separated by a hyphen follow ERA. that line and all lines following it are erased. Command: SAVE program-name w ired_gr. all lines preceeding it and that line are listed. the indicated lines and all lines between them are erased. Command: LIST { [start-line] .1/15/13 SmallBASIC Guide: completition). If a number followed by hyphen follows LIST.[end-line] } The LIST command allows you to display program lines. If two numbers separated by a hyphen follow LIST.users. Use keyword L A B E Lto define a label. If a number followed by hyphen follows ERA. all lines preceeding it and that line are erased. the entire program in memory is erased. Command: BYE Command: QUIT Command: EXIT The BYE command ends SmallBASIC and returns the control to the Operating System. use N U M . Command: NUM [initial-line [. If a number follows the LIST. there will be inserted automagically if you use '+' in the beginning of the line. If the 'initial-line' and 'increment' are not specified. are used only for editing. that line and all lines following it are listed. If ERA is entered with no numbers following it. Line numbers are not saved in files. Command: ERA { [start-line] . The symbol '?' does the same. Command: RUN [filename] The RUN command.] [increment] } The RENUM command allows you to reassign line numbers. If a number follows the ERA. Command: RENUM { [initial-line] [.1 Interactive Mode Commands Command: HELP [sb-keyword] Interactive mode help screen.html#SEC44 59/89 . If a number preceeded by a hyphen follows ERA. Command: CLS Clears the screen. increment]] The NUM command sets the values for the autonumbering. the line with that number is listed. Be sure to save the program that you have been working on before you enter NEW as it is unrecoverable by any means once NEW has been entered. the entire program in memory is listed. If LIST is entered with no numbers following it. the line with that number is erased. starts program execution. Line numbers are not labels. the indicated lines and all lines between them are listed.net/doc/sb9/guide. Command: NEW The NEW command clears the memory and screen and prepares the computer for a new program. the line numbers start at 10 and increase in increments of 10. There is no need to type line numbers. A.sourceforge.

you can later recall the program into memory. displays the current directory.1/15/13 SmallBASIC Guide: The SAVE command allows you to copy the program in memory to a file.m y s q l .m y s q l .h ?" D B S =" .CONNECT (host. Command: CD [path] Changed the current directory. d b s ( h ) ?" T A B L E S=" ." p a s s w o r d " ) ?" H a n d l e=" . You can use DIRE for executables only or DIRD for directories only. table) Get a list of the fields of a table Command: MYSQL. B. Without arguments. q u e r y ( h .m y s q l .DBS (handle) Get a list of the databases Function: MYSQL.FIELDS (handle.USE handle.net/doc/sb9/guide. MySQL Module Function: MYSQL. LOAD removes the program currently in memory before loading 'program-name'.sourceforge. d i s c o n n e c th w ired_gr. By using the LOAD command. c o n n e c t ( " l o c a l h o s t " . line-number The MERGE command merges lines in 'program-name' file into the program lines already in the computer's memory." S E L E C T*F R O Ms b x _ c o u n t e r s " ) m y s q l ." m y d a t a b a s e " . t a b l e s ( h ) ?" Q u e r y =" . user.QUERY (handle. Use 'line-number' to specify the position where the lines will be inserted. Command: TYPE filename Displays the contents of the file. database Changes the current database Example: i m p o r tm y s q l h=m y s q l . The program must first have been put on file using the SAVE command. Command: LOAD program-name The LOAD command loads 'program-name' file into memory. Command: MERGE program-name." u s e r " . [password]) Connects/reconnects to the server Function: MYSQL. database.DISCONNECT handle Disconnects Command: MYSQL. Command: DIR [regexp] Command: DIRE [regexp] Command: DIRD [regexp] Command: DIRB [regexp] Displays the list of files. or DIRB for BASIC sources. sqlstr) Send command to mysql server Function: MYSQL.users.html#SEC44 60/89 .TABLES (handle) Get a list of the tables Function: MYSQL.

users. ." k e y 1 " ) g d b m . f e t c h ( h . up to 16 variables 1023 bytes Maximum number of parameters 256 System events are checked every 50ms D. c l o s eh D. s t o r e ( h .2 PalmOS (Typical 16bit system) Length of text lines User-defined keyword length Number of array-dimensions w ired_gr. . GDBM Module Example: i m p o r tg d b m c o n s tG D B M _ W R C R E A T=2 'Aw r i t e r .h ?" S t o r er e t u r n s=" . 'T E S T h=g d b m ." d a t a 1 . <0=RGB) 256 notes 1023 characters per call. o p e n ( " d b t e s t .5 1 2 .g d b m . . Limits D.html#SEC44 511 characters 32 characters 3 61/89 Maximum number of parameters 32 . " ) ?" F e t c hr e t u r n s=" ." d a t a 2 . d b " .net/doc/sb9/guide.G D B M _ W R C R E A T .g d b m ." k e y 2 " ." k e y 1 " . C r e a t et h ed bi fn e e d e d .1/15/13 SmallBASIC Guide: C. s t o r e ( h .1 Typical 32bit system Bytecode size Length of text lines User-defined keyword length Numeric value range Maximum string size Number of file handles Number of array-dimensions Number of colors Background sound queue size INPUT (console) COMMAND$ 4 GB 4095 characters 128 characters 64 bit FPN (-/+ 1E+308) 2 GB 256 6 24 bit (0-15=VGA. . . .g d b m . " ) ?" S t o r er e t u r n s=" .sourceforge.0 o 6 6 6 ) ?" H a n d l e=" .

Writting Modules * Modules are working only at Linux for now * Modules are dynamic-linked libraries.1 Variables API Variables had 4 types. and return values. The 〈var_p〉 which is a var_t structure (a SB variable). slib_par_t *params. of course module authors can use other C or other-lib functions to do their jobs. int sblib_proc_getname(int index. int param_count. Returns 1 on success or 0 on error. The slib_par_t structure contains two fields. The modules are "connected" with the SmallBASIC with a two-way style. int sblib_proc_count() Returns the number of procedures of the module. int sblib_func_count() Returns the number of functions of the module. int param_count. the device's API must be used because SB can run in different environments.type 〈 V_STR〉 〈 V_INT〉 String.v. This type is described in . The value can be accessed at 〈. Module programmers will need to use variable's API to process parameters. 〈 V_ARRAY〉 . var_t *retval) Executes the 'index' procedure. Returns 1 on success or 0 on error. the module can execute functions of SB's library.p.Maximum string size Number of file handles Number of elements/array Bytecode size INPUT (console) COMMAND$ <32 KB 16 2970 (that means 64KB of memory) <64 KB (by using CHAIN you can run progs > 64KB) 255 characters per call. The value can be accessed at 〈.type field. E.v. Also. slib_par_t *params. int sblib_proc_exec(int index. and the 〈byref 〉 which is true if the variable can be used as by-reference. 〈 V_REAL〉 Real-number. int sblib_func_exec(int index. var_t *retval) Executes the 'index' function. Integer. Every module must implements the following C functions. char *name) Fills the 'name' variable with the name of the 'index'-th procedure.ptr〉. Returns 1 on success or 0 on error.n〉.v. That means. char *name) Fills the 'name' variable with the name of the 'index'-th function.i〉. Returns 1 on success or 0 on error. int sblib_func_getname(int index. The value can be accessed at 〈. Values of . up to 16 variables 127 bytes E.

a.sourceforge.t h e nt h i sf u n c t i o n * r u n sr e c u r s i v e . * / s t a t i cv o i dp r i n t _ v a r i a b l e ( i n tl e v e l . w ired_gr.i<v a r i a b l e > v . b r e a k .i<l e v e l .a n dt h e' l e v e l 'p a r a m e t e ri su s e d .ptr is the data pointer (sizeof(var_t) * size). v_free() and free() functions. i ) . b r e a k .v. var_t* v_new() Creates a new variable and returns it. p r i n t _ v a r i a b l e ( l e v e l + 1 . s i z e ) .i+ +){ v a r _ t* e l e m e n t _ p . The . The . s i z e .html#SEC44 63/89 .v a r i a b l e > v . . / *p r i n tv a r i a b l e* / s w i t c h(v a r i a b l e > t y p e) { c a s eV _ S T R : d e v _ p r i n t f ( " S t r i n g= \ " % s \ " \ n " . } b r e a k .v.net/doc/sb9/guide.1/15/13 SmallBASIC Guide: Array.a. } } E.v a r i a b l e > v .lbound[MAXDIM] is the lower bound values. / *i fr e c u r s i v e . v_free() and free() functions. a .p l a c et a b s* / f o r(i=0 . c a s eV _ I N T : d e v _ p r i n t f ( " I n t e g e r=% l d \ n " .i+ +) d e v _ p r i n t f ( " \ t " ) . The .v. v _ i n i t ( & m y v a r ) . The returned variable it must be freed with both. The .a. * I ft h ev a r i a b l ei sa na r r a y . v a r i a b l e > v . p t r+s i z e o f ( v a r _ t )*i ) . void v_set(var_t *dest. . void v_free(var_t *var) This function deletes the contents of varible 〈var〉. var_t *v_clone(const var_t *source) Returns a new variable which is a clone of 〈source〉. n ) .ubound[MAXDIM] is the upper bound values. b r e a k .v a r _ t* v a r i a b l e ) { i n ti . Example v o i d { m y f u n c ( ) v a r _ t m y v a r . e l e m e n t _ p=( v a r _ t* )( v a r i a b l e > v . c a s eV _ R E A L : d e v _ p r i n t f ( " R e a l=% .v. p t r ) .e l e m e n t _ p ) . a .1.a.users.a. p . f o r(i=0 . Example: / * * D i s p l a y sv a r i a b l ed a t a .1 Gereric void v_free(var_t *var) This function resets the variable to 0 integer. The returned variable it must be freed with both. The .v.size is the number of elements. a . c a s eV _ A R R A Y : d e v _ p r i n t f ( " A r r a yo f% de l e m e n t s \ n " .maxdim is the number of dimensions.v a r i a b l e > v . 2 f \ n " . const var_t *src) Copies the 〈src〉 to 〈dest 〉. .

const char *string) Sets the string value 〈string〉 to the variable 〈var〉. void v_strcat(var_t *var. int r. if 〈variable〉 is string it will converted to double. const char *string) Adds the string 〈string〉 to string-variable 〈var〉. void v_setint(var_t *var.1. void v_setstr(var_t *var. double number) Sets the 〈number〉 real-number value to 〈var〉 variable. int c) Converts the variable 〈var〉 to an array of 〈r〉 rows and 〈c〉 columns. The buffer size is limited to 1KB for OS_LIMITED (PalmOS). } E. E.1. char* v_getstr(var_t *var) Returns the string-pointer of variable 〈var〉. otherwise 64kB. int size) Resizes the 1-dimention 〈array〉.1.. 〈index 〉 is a zero-based. E.1. E.2 Real Numbers double v_getreal(var_t *variable) Returns the floating-point value of a variable.. const char *fmt.sourceforge. it must be converted to string with the v_tostr() function. index. void v_setstrf(var_t *var.1/15/13 SmallBASIC Guide: v _ f r e e ( & m y v a r ) . Each element of the arrays is a `‘v a r _ t ’' object. If the 〈var〉 is not a string. . void v_setreal(var_t *var.3 Integer Numbers double v_igetnum(var_t *variable) Returns the floating-point value of a variable. if 〈variable〉 is string it will converted to double.5 Arrays SB arrays are always one-dimension.net/doc/sb9/guide. int index) Returns the variable pointer of the element 〈index 〉 of the 〈array〉.users. void v_zerostr(var_t *var) Resets the variable 〈var〉 to a zero-length string. void v_resize_array(var_t *array. int v_asize(var_t *array) Returns the number of the elements of the 〈array〉. one dimention. void v_toarray1(var_t *var.html#SEC44 .4 Strings void v_tostr(var_t *arg) Converts variable 〈arg〉 to string. void v_tomatrix(var_t *var.) Sets a string value to variable 〈var〉 using printf() style. int32 number) Sets the 〈number〉 integer-number value to 〈var〉 variable. The multiple dimensions positions are calculated at run-time. var_t* v_elem(var_t *array. int n) w ired_gr.

2 0 .c _ a r r a y . } E.net/doc/sb9/guide. a .1/15/13 SmallBASIC Guide: Converts the variable 〈var〉 to an array of 〈n〉 elements.e l e m e n t _ p ) . The values (which are copied) are specified in 〈ctable〉. c a s eV _ R E A L : d e v _ p r i n t f ( " R e a l=% . v _ i n i t ( & m y v a r ) . int32 *itable.3 ) . } w ired_gr. char **ctable. int count) Makes variable 〈var〉 a real-number array of 〈count 〉 elements. The values are specified in 〈itable〉. p a r a m > v .c --# i n c l u d e< e x t l i b . * / s t a t i cv o i dp r i n t _ v a r i a b l e ( i n tl e v e l .p a r a m > v .mymod. c a s eV _ I N T : d e v _ p r i n t f ( " I n t e g e r=% l d \ n " . int count) Makes variable 〈var〉 a string array of 〈count 〉 elements. 2 f \ n " . e l e m e n t _ p=( v a r _ t* )( p a r a m > v .i+ +) d e v _ p r i n t f ( " \ t " ) . h > / * * D i s p l a y sv a r i a b l ed a t a . p r i n t _ v a r i a b l e ( l e v e l + 1 . p t r+s i z e o f ( v a r _ t )*i ) . c a s eV _ A R R A Y : d e v _ p r i n t f ( " A r r a yo f% de l e m e n t s \ n " . b r e a k . m y v a r .3 0} .users. v _ f r e e ( & m y v a r ) . int count) Makes variable 〈var〉 an integer array of 〈count 〉 elements.v a r _ t* p a r a m ) { i n ti . The values are specified in 〈rtable〉. s i z e . / *i fr e c u r s i v e . and the function "FUNCA" returns a string.p a r a m > v . void v_setintarray(var_t *var. b r e a k . a . n ) .t h e * ' l e v e l 'p a r a m e t e ri st h ec a l ll e v e l .html#SEC44 65/89 .i<p a r a m > v . p t r ) . f o r(i=0 . a . Example v o i d { m y f u n c ( ) i n t v a r _ t c _ a r r a y [ ]={1 0 .t h e nr u n sr e c u r s i v e . double *rtable. v _ s e t i n t a r r a y ( & m y v a r . void v_setrealarray(var_t *var.p l a c et a b s* / f o r(i=0 .2 Typical Module Source This is a typical example of a module with one Function and and one Command.sourceforge. s i z e ) . b r e a k . * I ft h ev a r i a b l ei sa na r r a y .p a r a m > v . void v_setstrarray(var_t *var. --. } b r e a k . The command "CMDA" displays its parameters.i<l e v e l . / *p r i n tv a r i a b l e* / s w i t c h(p a r a m > t y p e) { c a s eV _ S T R : d e v _ p r i n t f ( " S t r i n g= \ " % s \ " \ n " . p . i ) .i+ +){ v a r _ t* e l e m e n t _ p .

N U L L} } . r e t u r n1 .v a r _ t* r e t v a l ) { v _ s e t s t r ( r e t v a l . }m o d _ k w . } w ired_gr./ /c o m m a n dA {N U L L . / *s u c c e s s* / } / *t h en o d e t y p eo ff u n c t i o n / p r o c e d u r et a b l e s* / t y p e d e fs t r u c t{ c h a r* n a m e .i<p a r a m _ c o u n t .p a r a m ) .users.c h a r* p r o c _ n a m e ) { s t r c p y ( p r o c _ n a m e . r e t u r ni . f o r(i=0 .v a r _ t* ) .net/doc/sb9/guide. / *c o m m a n d st a b l e* / s t a t i cm o d _ k wp r o c _ n a m e s [ ]= { {" C M D A " .m _ c m d A} .f u n c _ n a m e s [ i n d e x ] .html#SEC44 66/89 .i n t .p r o c _ n a m e s [ i n d e x ] . } / *r e t u r n st h en u m b e ro ft h ef u n c t i o n s* / i n ts b l i b _ f u n c _ c o u n t ( v o i d ) { i n ti .i+ +) . f o r(i=0 . } / *r e t u r n st h e' i n d e x 'p r o c e d u r en a m e* / i n ts b l i b _ p r o c _ g e t n a m e ( i n ti n d e x . f o r(i=0 .v a r _ t* r e t v a l ) { i n ti . n a m e .N U L L} } .1/15/13 SmallBASIC Guide: } / *t y p i c a lc o m m a n d* / v o i dm _ c m d A ( i n tp a r a m _ c o u n t . p r i n t _ v a r i a b l e ( 0 .i+ +){ p a r a m=p a r a m s [ i ] . } / *r e t u r n st h e' i n d e x 'f u n c t i o nn a m e* / i n ts b l i b _ f u n c _ g e t n a m e ( i n ti n d e x .i+ +) . v a r _ p . n a m e .s l i b _ p a r _ t* p a r a m s .sourceforge. } } / *t y p i c a lf u n c t i o n* / i n tm _ f u n c A ( i n tp a r a m _ c o u n t . n a m e ) . r e t u r n1 . / *t h en a m eo ft h ef u n c t i o n* / i n t ( * c o m m a n d ) ( s l i b _ p a r _ t* . / *r e t u r n st h en u m b e ro ft h ep r o c e d u r e s* / i n ts b l i b _ p r o c _ c o u n t ( v o i d ) { i n ti .m _ f u n c A} .s l i b _ p a r _ t* p a r a m s .p r o c _ n a m e s [ i ] . n a m e ) . / *f u n c t i o n st a b l e* / s t a t i cm o d _ k wf u n c _ n a m e s [ ]= { {" F U N C A " .f u n c _ n a m e s [ i ] .c h a r* p r o c _ n a m e ) { s t r c p y ( p r o c _ n a m e ." f u n c A ( )w o r k s ! " ) ./ /f u n c t i o nA {N U L L . r e t u r n1 . r e t u r ni .

This organization produces many standards. s o n a m e . o g c cs h a r e dW l . 〈 CFLAGS〉 Compilers flags.users. --. among them the standards for the C and C++ programming languages. The SB's module directory.r e t v a l ) . The variables of Makefile 〈 MODNAME〉 〈 MODLIBS〉 〈 MODIDIR〉 〈 CINC〉 The name of the module The libraries that are required by the module. o$ ( M O D L I B S ) m v$ ( M O D N A M E ) .p a r a m _ c o u n t .r e t v a l ) .v a r _ t* r e t v a l ) {r e t u r np r o c _ n a m e s [ i n d e x ] .sourceforge. s o$ ( M O D I D I R ) l d c o n f i gn$ ( M O D I D I R ) c l e a n : r mf* . w ired_gr.} E. s l i b _ p a r _ t* p a r a m s .c'.} / *e x e c u t et h e' i n d e x 'f u n c t i o n* / i n ts b l i b _ f u n c _ e x e c ( i n ti n d e x .3 Typical Module Makefile This is a typical Makefile. s o :$ ( M O D N A M E ) . s o$ ( M O D N A M E ) . There will be installed the module.i n tp a r a m _ c o u n t . s o* . o$ ( M O D I D I R ) / $ ( M O D N A M E ) . Also. s l i b _ p a r _ t* p a r a m s . See also "ISO". s oo$ ( M O D N A M E ) .1/15/13 SmallBASIC Guide: / *e x e c u t et h e' i n d e x 'p r o c e d u r e* / i n ts b l i b _ p r o c _ e x e c ( i n ti n d e x .p a r a m _ c o u n t .i n tp a r a m _ c o u n t . s o F. In our example the module name is 'mymod' and its source is the 'mymod. co$ ( M O D N A M E ) .net/doc/sb9/guide. Glossary What it could be good to know.html#SEC44 . $ ( M O D N A M E ) . s o $ ( M O D I D I R ) / $ ( M O D N A M E ) . This must points to the SB source files. ANSI The American National Standards Institute. c o m m a n d ( p a r a m s . 'Include' path.Makefile --M O D N A M E = m y m o d M O D L I B S = l m y s q l c l i e n t M O D I D I R = / u s r / l i b / s b a s i c / m o d u l e s C I N C = I / o p t / s b a s i c / s o u r c e C F L A G S = W a l lf P I C$ ( C I N C )D _ U n i x O SD L N X _ E X T L I B a l l :$ ( M O D I D I R ) / $ ( M O D N A M E ) . our module is requires the 'mysqlclient' library to be linked together. c o m m a n d ( p a r a m s .v a r _ t* r e t v a l ) {r e t u r nf u n c _ n a m e s [ i n d e x ] . c m k d i rp$ ( M O D I D I R ) g c c$ ( C F L A G S )c$ ( M O D N A M E ) .

. Bit Short for "Binary Digit"..sourceforge. Computers are often defined by how many bits they use to represent integer values. An on-going project of the Free Software Foundation to create a complete. w ired_gr. It is the time of day used as the epoch for Unix and POSIX systems.1/15/13 SmallBASIC Guide: Program An program consists of a series of commands. Typical examples are the environment variables H O M Eand P A T H . that each program has available to it. Environment Variables A collection of strings.html#SEC44 68/89 . punctuation. numbers. Compiler A program that translates human-readable source code into machine-executable object code. It was founded by Richard M. See also "Interpreter". GMT "Greenwich Mean Time". Flag A variable whose truth value indicates the existence or nonexistence of some condition. freely distributable. of the form 〈name= val〉. The object code is then executed directly by the computer or by a virtual-machine. POSIX-compliant computing environment. . With few words. and 16bit systems are waning in popularity. GPL allows source code and binary forms to be used copied and modified freely. Script Another name for an program. such as `‘\ n ’' for newline or `‘\ 0 3 3 ’' for the ASCII ESC (Escape) character. Stallman. Typical systems are 32-bit systems. Free Software Foundation FSF A nonprofit organization dedicated to the production and distribution of freely distributable software. statements. Users generally place values into the environment in order to provide information to various programs. but 64-bit systems are becoming increasingly popular. and their source code may be distributed.users. All values in computer memory ultimately reduce to binary digits: values that are either zero or one. etc. Many European countries use an extension of ASCII known as ISO-8859-1 (ISO Latin-1). Escape Sequences A special sequence of characters used for describing nonprinting characters. The most common character set in use today is ASCII (American Standard Code for Information Interchange). and expressions. GNU "GNU's not Unix". Character Set The set of numeric codes used by a computer system to represent the characters (letters.net/doc/sb9/guide. The program executed by an interpreted language command by command until it ends. Deadlock The situation in which two communicating processes are each waiting for the other to perform an action.) of a particular country or place. GNU General Public License GNU GPL This document describes the terms under which binary library archives or shared objects.

including programming languages. Thus. You can redirect input to the I N P U Tstatement using the `‘< ’'. Private Variables and/or functions that are meant for use exclusively by this level of functions and not for the main program. RegExp Regulat Expression Short for regular expression. `‘B ’' representing 11. but runs well on a variety of other systems too.1/15/13 SmallBASIC Guide: GNU/Linux A variant of the GNU system using the Linux kernel.html#SEC44 69/89 . the regexp `‘R . to indicate their base. A regexp is a pattern that denotes a set of strings. & o 1 3is 11 (one times 8 plus 3). to indicate their base. `‘> > ’'. ISO The International Standards Organization. See L O C A L . In Unices. For example. Recursion When a function calls itself. w ired_gr. The Linux kernel source code is available under the terms of the GNU General Public License. either directly or indirectly. and so on. the act of moving data into and/or out of a running program. possibly an infinite set. or performing output to something other than the standard output stream. Redirection Redirection means performing input from something other than the standard input stream. and their source code may be distributed. and `‘| & ’' operators. where the digits are 0 --7 .sourceforge. It uses the instructions in it to process data and produce results. efficient. POSIX The name for a series of standards that specify a Portable Operating System interface. 0 x 1 2is 18 (1 times 16 plus 2). Octal numbers are written in SB using a leading `‘& o ’'. "Nested Functions". full-featured clone of Unix that has been ported to a variety of architectures. Hexadecimal Base 16 notation. `‘| ’'. The "IX" denotes the Unix heritage of these standards. which is perhaps its most important aspect. Lesser General Public License LGPL This document describes the terms under which binary library archives or shared objects. I/O Abbreviation for "Input/Output". a list of directories to search for executable programs. you can redirect the output of the p r i n tstatements to a file or a system command. Linux is a stable. Octal Base-eight notation. and `‘| & ’' operators.users. where the digits are 0 --9and A --F . `‘| ’'. Interpreter A program that reads and executes human-readable source code directly. * x p ’' matches any string starting with the letter `‘R ’' and ending with the letters `‘x p ’'. Hexadecimal numbers are written in SB using a leading `‘0 x ’' or `‘& H ’'. using the `‘> ’'. Search Path In SB. up to `‘F ’' for 15. This organization produces international standards for many things. In the shell. instead of the Free Software Foundation's Hurd kernel. such as C and C++. Thus. with `‘A ’' representing 10. It is most popular on PC-class systems. a list of directories to search for SB program files.net/doc/sb9/guide.

it can be used for any textual work. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License.users.sourceforge. But this License is not limited to software manuals. Any member of the public is a licensee. below. Boston. 2. The "Document". March 2000 Copyright (C) 2000 Free Software Foundation. GNU Free Documentation License Version 1. while not being considered responsible for modifications made by others. for a sequence of random numbers. Suite 330.1/15/13 SmallBASIC Guide: Seed The initial value. FreeBSD. DOS and WinNT/2K/XP (CMD). which means that derivative works of the document must themselves be free in the same sense. NetBSD. with or without modifying it. Shell The command interpreter for Unix. and as a programming language for batch files. PREAMBLE The purpose of this License is to make a manual.html#SEC44 70/89 . because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. 59 Temple Place. There are many commercial versions of Unix. or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it. regardless of subject matter or whether it is published as a printed book. The shell works both interactively. but changing it is not allowed. as well as several work-alike systems whose source code is freely available (such as GNU/Linux. We have designed this License in order to use it for manuals for free software. or shell scripts. and is addressed as "you". either commercially or noncommercially. This License is a kind of "copyleft". refers to any such manual or work. MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document.1. which is a copyleft license designed for free software. It initially became popular in universities around the world and later moved into commercial environments as a software development system and network server system. We recommend this License principally for works whose purpose is instruction or reference. and OpenBSD). It complements the GNU General Public License. textbook. Secondarily. this License preserves for the author and publisher a way to get credit for their work. Unix A computer operating system originally developed in the early 1970's at AT&T Bell Laboratories. Inc. G. POSIX-compliant systems. or starting point.net/doc/sb9/guide. 1. w ired_gr.

in the notice that says that the Document is released under this License. A "Transparent" copy of the Document means a machine-readable copy. the material this License requires to appear in the title page. ethical or political position regarding them.) The relationship could be a matter of historical connection with the subject or with related matters. either commercially or noncommercially. VERBATIM COPYING You may copy and distribute the Document in any medium. (For example. However. represented in a format whose specification is available to the general public. proprietary formats that can be read and edited only by proprietary word processors. A copy that is not "Transparent" is called "Opaque".1/15/13 SmallBASIC Guide: A "Modified Version" of the Document means any work containing the Document or a portion of it. and standard-conforming simple HTML designed for human modification. For works in formats which do not have any title page as such. philosophical. as being those of Invariant Sections. commercial. 3. SGML or XML for which the DTD and/or processing tools are not generally available. If you distribute a large enough number of copies you must also follow the w ired_gr. provided that this License. Opaque formats include PostScript. and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. either copied verbatim. and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. The "Cover Texts" are certain short passages of text that are listed.html#SEC44 71/89 . if the Document is in part a textbook of mathematics.users. and the license notice saying this License applies to the Document are reproduced in all copies. for a printed book. the copyright notices. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. you may accept compensation in exchange for copies. a Secondary Section may not explain any mathematics. as Front-Cover Texts or Back-Cover Texts. LaTeX input format. or of legal. Texinfo input format. plus such following pages as are needed to hold. PDF. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. or with modifications and/or translated into another language. Examples of suitable formats for Transparent copies include plain ASCII without markup. in the notice that says that the Document is released under this License. legibly. "Title Page" means the text near the most prominent appearance of the work's title.net/doc/sb9/guide. and the machine-generated HTML produced by some word processors for output purposes only. The "Title Page" means. SGML or XML using a publicly available DTD. preceding the beginning of the body of the text. The "Invariant Sections" are certain Secondary Sections whose titles are designated. the title page itself.sourceforge. whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor.

If the required texts for either cover are too voluminous to fit legibly. 5. Copying with changes limited to the covers. as long as they preserve the title of the Document and satisfy these conditions. You may also lend copies. you must either include a machine-readable Transparent copy along with each Opaque copy. List on the Title Page. all these Cover Texts: Front-Cover Texts on the front cover. under the same conditions stated above. or state in or with each Opaque copy a publicly-accessible computernetwork location containing a complete Transparent copy of the Document. if there were any. that you contact the authors of the Document well before redistributing any large number of copies. clearly and legibly. together with at least five of the principal authors of the Document (all of w ired_gr. COPYING IN QUANTITY If you publish printed copies of the Document numbering more than 100. you must do these things in the Modified Version: 1. you must take reasonably prudent steps. and you may publicly display copies. 4. If you use the latter option. You may add other material on the covers in addition. The front cover must present the full title with all words of the title equally prominent and visible. with the Modified Version filling the role of the Document. you should put the first ones listed (as many as fit reasonably) on the actual cover. 2. and continue the rest onto adjacent pages. if any) a title distinct from that of the Document.net/doc/sb9/guide. and Back-Cover Texts on the back cover. which the general network-using public has access to download anonymously at no charge using public-standard network protocols. free of added material. be listed in the History section of the Document). one or more persons or entities responsible for authorship of the modifications in the Modified Version. and from those of previous versions (which should. thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. but not required.1/15/13 SmallBASIC Guide: conditions in section 3. to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. when you begin distribution of Opaque copies in quantity. you must enclose the copies in covers that carry. and the Document's license notice requires Cover Texts. Both covers must also clearly and legibly identify you as the publisher of these copies. In addition. to give them a chance to provide you with an updated version of the Document. If you publish or distribute Opaque copies of the Document numbering more than 100.sourceforge. can be treated as verbatim copying in other respects. It is requested. as authors. You may use the same title as a previous version if the original publisher of that version gives permission. provided that you release the Modified Version under precisely this License. Use in the Title Page (and on the covers. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above.html#SEC44 72/89 .users.

3. Delete any section entitled "Endorsements". Include. year. new authors. if it has less than five). year.html#SEC44 73/89 . Preserve all the copyright notices of the Document. 4. immediately after the copyright notices. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. Such a section may not be included in the Modified Version. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself. a license notice giving the public permission to use the Modified Version under the terms of this License. then add an item describing the Modified Version as stated in the previous sentence. and publisher of the Document as given on its Title Page. These titles must be distinct from any other section titles. 9. Preserve the network location. and likewise the network locations given in the Document for previous versions it was based on. in the form shown in the Addendum below. 10.1/15/13 SmallBASIC Guide: its principal authors. If there is no section entitled "History" in the Document. and publisher of the Modified Version as given on the Title Page. preserve the section's title. given in the Document for public access to a Transparent copy of the Document. 8. 13.net/doc/sb9/guide. Preserve the section entitled "History". 5. add their titles to the list of Invariant Sections in the Modified Version's license notice.users. 12. provided it contains nothing but endorsements of your Modified Version by various parties--for example. authors. State on the Title page the name of the publisher of the Modified Version. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. You may add a section entitled "Endorsements". you may at your option designate some or all of these sections as invariant. Preserve all the Invariant Sections of the Document. create one stating the title. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document. 14. In any section entitled "Acknowledgements" or "Dedications". or if the original publisher of the version it refers to gives permission. Include an unaltered copy of this License. 11. and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. 7. if any. as the publisher. unaltered in their text and in their titles. To do this. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section. Section numbers or the equivalent are not considered part of the section titles. statements of w ired_gr. and its title. 6. and add to it an item stating at least the title.sourceforge.

You may extract a single document from such a collection. provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. and follow this License in all other respects regarding verbatim copying of that document. in parentheses. you may not add another. but you may replace the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. provided you insert a copy of this License into the extracted document. You may add a passage of up to five words as a Front-Cover Text. 8. you must combine any sections entitled "History" in the various original documents. If there are multiple Invariant Sections with the same name but different contents. likewise combine any sections entitled "Acknowledgements". on explicit permission from the previous publisher that added the old one. and replace the individual copies of this License in the various documents with a single copy that is included in the collection. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. and list them all as Invariant Sections of your combined work in its license notice. COMBINING DOCUMENTS You may combine the Document with other documents released under this License. the name of the original author or publisher of that section if known. forming one section entitled "History". previously added by you or by arrangement made by the same entity you are acting on behalf of. make the title of each such section unique by adding at the end of it. and multiple identical Invariant Sections may be replaced with a single copy. provided that you include in the combination all of the Invariant Sections of all of the original documents. You must delete all sections entitled "Endorsements. or else a unique number. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License. provided w ired_gr. unmodified. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works. The combined work need only contain one copy of this License. In the combination. and distribute it individually under this License. under the terms defined in section 4 above for modified versions.sourceforge. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. does not as a whole count as a Modified Version of the Document. to the end of the list of Cover Texts in the Modified Version.users." 7. in or on a volume of a storage or distribution medium.html#SEC44 74/89 . and a passage of up to 25 words as a Back-Cover Text. 6.1/15/13 SmallBASIC Guide: peer review or that the text has been approved by an organization as the authoritative definition of a standard. and any sections entitled "Dedications". If the Document already includes a cover text for the same cover.net/doc/sb9/guide.

sublicense or distribute the Document is void. TERMINATION You may not copy. G. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new.net/doc/sb9/guide. If the Cover Text requirement of section 3 is applicable to these copies of the Document. revised versions of the GNU Free Documentation License from time to time. and will automatically terminate your rights under this License. However.users. In case of a disagreement between the translation and the original English version of this License. Otherwise they must appear on covers around the whole aggregate. sublicense. but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. Such new versions will be similar in spirit to the present version. 9. on account of their being thus compiled. and this License does not apply to the other self-contained works thus compiled with the Document. modify. 10. TRANSLATION Translation is considered a kind of modification. so you may distribute translations of the Document under the terms of section 4.gnu. modify. include a copy of the License in the document and put the following copyright and license notices just after the title page: w ired_gr. 11. you may choose any version ever published (not as a draft) by the Free Software Foundation. parties who have received copies.org/copyleft/. If the Document does not specify a version number of this License. Any other attempt to copy. then if the Document is less than one quarter of the entire aggregate.1 ADDENDUM: How to use this License for your documents To use this License in a document you have written. from you under this License will not have their licenses terminated so long as such parties remain in full compliance.html#SEC44 75/89 . Replacing Invariant Sections with translations requires special permission from their copyright holders.1/15/13 SmallBASIC Guide: no compilation copyright is claimed for the compilation. or rights. or distribute the Document except as expressly provided for under this License. See http://www. the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. if they are not themselves derivative works of the Document. You may include a translation of this License provided that you also include the original English version of this License. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it.sourceforge. but may differ in detail to address new problems or concerns. you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. the original English version will prevail. Such a compilation is called an "aggregate".

1 o ra n yl a t e rv e r s i o np u b l i s h e db yt h eF r e eS o f t w a r eF o u n d a t i o n .6 Meta-commands 2. P e r m i s s i o ni sg r a n t e dt oc o p y .3 Trigonometry 9. Mathematics 9.6 Meta-commands 2. Commands 6.6 Graphics Commands 11. their titles〉 . Mathematics 9. Strings 9. Command Index Jump to: # A B C D E F G H I J K L M N O P Q R S T U V W X Y Index Entry # # ! .3 Trigonometry 4.users.d i s t r i b u t ea n d / o rm o d i f yt h i sd o c u m e n t u n d e rt h et e r m so ft h eG N UF r e eD o c u m e n t a t i o nL i c e n s e . w i t ht h e If you have no Invariant Sections. to permit their use in free software.3 Trigonometry 9. Ac o p yo ft h el i c e n s ei si n c l u d e di nt h es e c t i o ne n t i t l e d` ` G N U F r e eD o c u m e n t a t i o nL i c e n s e ' ' .6 Meta-commands 2. If you have no Front-Cover Texts. a n dw i t ht h eB a c k C o v e rT e x t sb e i n g 〈 list 〉 . write "no Front-Cover Texts" instead of "Front-Cover Texts being 〈list 〉". .6 Meta-commands A A B S A B S M A X A B S M I N A C C E S S A C O S A C O S H A C O T A C O T H A C S C A C S C H A P P E N D A R C A S C A S E C A S E C H A S I N A S I N H 9.3 Trigonometry 9.3 Trigonometry 76/89 9. H.3 Trigonometry 9. . # i n c : # s e c : # u n i t p a t h : Section 2.1/15/13 SmallBASIC Guide: C o p y r i g h t( C ) 〈 year〉 〈 your name〉 .3 Trigonometry w ired_gr. Mathematics 8.3 Trigonometry 9.V e r s i o n1 .sourceforge.2 File System Commands 9. such as the GNU General Public License.3 Trigonometry 9. likewise for Back-Cover Texts. If your document contains nontrivial examples of program code.net/doc/sb9/guide. we recommend releasing these examples in parallel under your choice of free software license. write "with no Invariant Sections" instead of saying which ones are invariant.3 Trigonometry 9.html#SEC44 . w i t ht h eI n v a r i a n tS e c t i o n sb e i n g 〈 list F r o n t C o v e rT e x t sb e i n g 〈 list 〉 .

6 Graphics Commands 8.3 Trigonometry 9.3 Trigonometry 9. Commands 8. System 11.2 File System Commands 9. Strings A.users. System 5.3 Trigonometry 9. Miscellaneous 6.2 File System Commands 11. Strings 7.net/doc/sb9/guide.2 File System Commands 5.1 Interactive Mode Commands C C A T C B S C D C D B L C E I L C H A I N C H A R T C H D I R C H M O D C H O P C H R C I N T C I R C L E C L O S E C L S C L S C O L O R C O N S T C O P Y C O S C O S H C O T C O T H C R E A L 12. Miscellaneous 77/89 w ired_gr.3 Trigonometry 9. Strings 6.2 Console Commands 11.3 Trigonometry B B A L L O C B C O P Y B C S B E E P B G E T C B I N B L O A D B P U T C # B S A V E B Y E 5.3 Trigonometry 9.2 File System Commands 12.1 Interactive Mode Commands 6. System 8.2 Round 5.6 Graphics Commands 8. Strings 11.2 Console Commands 9.sourceforge.2 File System Commands 8. Strings 5.2 File System Commands 11. System A.html#SEC44 . Miscellaneous 9.3 Trigonometry 7.3 Trigonometry 9.6 Graphics Commands 8.2 Console Commands A.6 Graphics Commands 4.1/15/13 SmallBASIC Guide: A S I N H A T A T A N A T A N 2 A T A N H A T N 9.3 Trigonometry 12.1 Interactive Mode Commands 7. System 6.

Commands 9. System 4.3 Trigonometry 9. System 9. System 5.sourceforge.net/doc/sb9/guide.6 Equations 9. Commands A.1 Interactive Mode Commands A. Commands 5.users. System 5. Commands A. Commands 11.2 File System Commands A. System 5.2 File System Commands 11.3 Trigonometry D D A T A D A T E D A T E D M Y D A T E F M T D E G D E L A Y D E L E T E D E R I V D E T E R M D I F F E Q N D I M D I R D I R B D I R D D I R E D I R W A L K D I S C L O S E D R A W D R A W P O L Y 4.1 Interactive Mode Commands 9.2 File System Commands 4. Commands 5.1 Unit convertion 5.6 Equations 4.1 Interactive Mode Commands 8.4 Logarithms 9. Mathematics F F I L E S 8. System 5.1 Interactive Mode Commands 4.6 Graphics Commands E E M P T Y E N C L O S E E N D E N V E N V E N V I R O N E N V I R O N E O F E R A E R A S E E X E C E X I S T E X I T E X I T E X P E X P R S E Q 4.6 Equations 9. Commands 5.2 File w ired_gr. System 5.1 Interactive Mode Commands A. Strings 6.6 Graphics Commands 6.1 Interactive Mode Commands A.1/15/13 SmallBASIC Guide: C S C C S C H 9.html#SEC44 System Commands 78/89 . System 8. System 8. Strings 4.

2 File System Commands F I X F L O O R F O R F O R F O R M A T F R A C F R E F R E E F I L E 9.2 Round 9. 2D Algebra 9. Commands 11.html#SEC44 .users. Commands 4. System K K I L L 8.2 File System Commands 8.2 Round 5.2 File System Commands 79/89 w ired_gr. Commands 4. Commands H H E L P H E X A. Commands 4. System 8.2 Console Commands 8.6 Equations 4.2 Round 10. Commands 11.2 Round 4.2 File System Commands 4.1 Interactive Mode Commands 11. Commands J J O I N J U L I A N 11. Strings 5. Strings 9. Commands 12.2 File System Commands 4.2 Console Commands 8. Commands 8.2 File System Commands 12. Commands 4.2 File System Commands 8.1/15/13 SmallBASIC Guide: 8. Strings I I F I F I N K E Y I N P U T I N P U T I N P U T # I N S E R T I N S T R I N T I N T E R S E C T I N V E R S E I S A R R A Y I S D I R I S F I L E I S L I N K I S N U M B E R I S S T R I N G 4.net/doc/sb9/guide. Strings 9.sourceforge.2 File System Commands G G O S U B G O T O 4.

Strings 11.6 Graphics Commands 12. Commands 6. Mathematics 8.4 Logarithms 5.1 2D & 3D graphics transformations 10. MySQL Module M Y S Q L .1 2D & 3D graphics transformations 10. Strings 4. Commands 7. MySQL Module B. Strings 11. Strings 11. Strings M M 3 A P P L Y M 3 I D E N T M 3 R O T A T E M 3 S C A L E M 3 T R A N S M A L L O C M A X M E R G E M I D M I N M K D I R M Y S Q L .1 Interactive Mode Commands 12. MySQL Module MySQL Module B. System 9.2 Console Commands 8. Strings 11. Commands 4. Strings 9. Miscellaneous 11.2 File System Commands B.1 2D & 3D graphics transformations 10.1 2D & 3D graphics transformations 5.2 Console Commands 8. Mathematics A.2 File System Commands A. M Y S Q L . MySQL Module B.2 File System Commands 9.1 Interactive Mode Commands A.1 2D & 3D graphics transformations 10.1 Interactive Mode Commands 11. Q U E R Y .2 Console Commands 8.2 Console Commands 8.2 File System Commands 9. D I S C O N N E C TB. F I E L D S M Y S Q L .4 Logarithms 9.6 Equations 12.L L A B E L L B O U N D L C A S E L E F T L E F T O F L E F T O F L A S T L E N L E T L I N E L I N E I N P U T L I N E I N P U T # L I N E Q N L I N EI N P U T L I N EI N P U T # L I N P U T L I N P U T # L I S T L O A D L O C A T E L O F L O G L O G 1 0 L O G P R I N T L O W E R L T R I M 4.2 File System Commands 12. System 11. D B S 10. C O N N E C T M Y S Q L .

Miscellaneous 7. Commands 81/89 w ired_gr.2 File System Commands 2. 2D Algebra 10. Miscellaneous 5.6 Graphics Commands 10. T A B L E S M Y S Q L .html#SEC44 . Mathematics 12. 2D Algebra 9.1 Interactive Mode Commands R R A D R A N D O M I Z E R E A D 9.2 Console Commands 8.2 File System Commands 6.1 Unit convertion 7.1 Run-Time 2. MySQL Module N N E W N O S O U N D N U M A. System 10.6 Graphics Commands 7. 2D Algebra 10.5. U S E B.1 Interactive Mode Commands 6.users.5. 2D Algebra 10.net/doc/sb9/guide.1 Interactive Mode Commands O O C T O N O P E N O P T I O N O P T I O N O P T I O N O P T I O N 11. System 7. Miscellaneous 6.6 Graphics Commands 6.1/15/13 SmallBASIC Guide: B. Miscellaneous 4.6 Graphics Commands 5.5 The OPTION keyword 2.sourceforge.1 Run-Time 2. 2D Algebra Q Q U I T A.6 Graphics Commands 6. MySQL Module M Y S Q L .2 Compile-Time P P A I N T P A U S E P E E K [ { 1 6 | 3 2 } ] P E N P E N P L A Y P L O T P O I N T P O K E [ { 1 6 | 3 2 } ] P O L Y A R E A P O L Y E X T P O W P R I N T P R I N T # P S E T P T D I S T L N P T D I S T S E G P T S I G N 6.5. Strings 4. MySQL Module B.6 Graphics Commands A. Commands 8.

Strings 11. System 11. Strings 11.2 File System Commands 10. System 6. Strings 82/89 11.2 File System Commands 7.sourceforge. Strings 11.6 Graphics Commands 11. Commands 6. Strings 5. Mathematics 9.1 Interactive Mode Commands S S A V E S E A R C H S E C S E C H S E E K S E E K # S E G C O S S E G L E N S E G S I N S E Q S G N S I N S I N H S I N P U T S O R T S O U N D S P A C E S P C S P L I T A.6 Equations 9. System 9. Commands 8.3 Trigonometry 9.2 File System Commands 8.6 Graphics Commands 6.html#SEC44 .3 Trigonometry 11.6 Graphics Commands 4. 2D Algebra 9.3 Trigonometry 8. Strings 5. Strings 4. System 5. Miscellaneous 9.1 Interactive Mode Commands 4. Commands 11. Strings w ired_gr.2 File System Commands A. Strings 8.3 Trigonometry 9. 2D Algebra 10. System A.1 Interactive Mode Commands 5.1/15/13 SmallBASIC Guide: R E A D # R E C T R E M R E N A M E R E N U M R E P E A T R E P L A C E R E S T O R E R E T U R N R G B R G B F R I G H T R I G H T O F R I G H T O F L A S T R I N S T R R M D I R R N D R O O T R O U N D R T E R T R I M R U N R U N R U N 8.6 Graphics Commands 11. Mathematics 9. 2D Algebra 10.net/doc/sb9/guide.2 Round 5.users. Commands 4.2 File System Commands 6. Strings 11.

6 Graphics Commands 5.1 Interactive Mode Commands U U B O U N D U C A S E U P P E R U S R C A L L 7. System 5. System 8. System 4. Strings 5. Mathematics 11.2 File System Commands 11.6 Graphics Commands 6.5 Statistics 9. Miscellaneous 11. Strings 11.3 Trigonometry 6.6 Graphics Commands A.5 Statistics 9. Strings 11.1/15/13 SmallBASIC Guide: S P L I T S P R I N T S Q R S Q U E E Z E S T A T M E A N S T A T M E A N D E V S T A T S P R E A D P S T A T S P R E A D S S T K D U M P S T O P S T R S T R I N G S U M S U M S Q S W A P 11.2 File System Commands 6. Strings 9.net/doc/sb9/guide. System 5. Strings 9. Strings 11.sourceforge.5 Statistics 5.users.html#SEC44 .6 Graphics Commands 6. System 5. Strings 5. Strings 9.5 Statistics 9. System 5. System V V A D R 5. System 8. System 83/89 w ired_gr. System 5. Strings 11.5 Statistics 9. Commands 11.5 Statistics 7. Miscellaneous T T A N T A N H T E X T H E I G H T T E X T W I D T H T I C K S T I C K S P E R S E C T I M E T I M E H M S T I M E R T L O A D T R A N S L A T E T R I M T R O F F T R O N T S A V E T X T H T X T W T Y P E 9.3 Trigonometry 9.

html#SEC44 84/89 2. System 4.sourceforge. Commands 6.6 Graphics Commands W W E E K D A Y W H I L E W I N D O W W R I T E # 5.6 Graphics Commands 8.1/15/13 SmallBASIC Guide: V A L V I E W 11.6 Graphics Commands Jump to: # A B C D E F G H I J K L M N O P Q R S T U V W X Y I.2 System Variables H H O M E H O M E w ired_gr.2 System Variables 2.2 System Variables 2. Strings 6.2 File System Commands X X P O S 6.users.2 System Variables .2 System Variables 2. Variable Index Jump to: B C F H O P S T V X Y Index Entry Section B B P P B P P 2.net/doc/sb9/guide.2 System Variables 2.2 System Variables F F A L S E F A L S E 2.2 System Variables C C O M M A N D C O M M A N D C W D C W D 2.2 System Variables 2.6 Graphics Commands Y Y P O S 6.

2 System Variables X X M A X X M A X 2.2.2 System Variables 2.sourceforge.2 System Variables 2.1.2 System Variables 2.2 System Variables 2.1 About BASIC 1.2 System Variables S S B V E R S B V E R 2.2 System Variables 2.users.2 System Variables O O S N A M E O S N A M E O S V E R O S V E R 2.2 System Variables 2.1.2 System Variables 2.1 Purpose w ired_gr.1.2 System Variables P P I P I 2.2 System Variables Jump to: B C F H O P S T V X Y [Top ] [Contents ] [Index] [ ? ] Table of Contents 1.2 System Variables V V I D A D R V I D A D R 2.html#SEC44 85/89 .2 System Variables 2.2 System Variables T T R U E T R U E 2. Introduction 1.2 System Variables 2.1 Welcome to SmallBASIC 1.1/15/13 SmallBASIC Guide: 2.2 System Variables Y Y M A X Y M A X 2.net/doc/sb9/guide.2 About SmallBASIC 1.

2 Compile-Time 2.1 The colors 6.18 The DO keyword 3.1.3 Running SB Interactively 1.html#SEC44 86/89 .16 The pseudo-operators ++/--/p= 2.3 Loops and expressions 4.2.9 The operator IN 2.5.10 The operator LIKE 2. Graphics & Sound 6.net/doc/sb9/guide.1.2.5.1 Using L O C A Lvariables 3. The language 2.17 The USE keyword 2.6 Constants 2.2 About the dollar-symbol 2.6 Meta-commands 2.1.1 Variable names 2.1 What we must already know 1.2 The points 6. System 6.11 The pseudo-operator << 2.1.8 Nested arrays 2.3 The STEP keyword 6.4.2 System Variables 2.sourceforge.3 Operators 2.4 The 'aspect' parameter 6.4 Reals 2.5 Strings 2.1.15 Units (SB libraries) 2. Programming Tips 3.users.5 The OPTION keyword 2.4 Running SB 1.2. Commands 5.7 Arrays and Matrices 2.2 Cross-platform 1.4 Special Characters 2.1.12 Subroutines and Functions 2.13 Single-line Functions 2.3 Integers 2.1.1/15/13 SmallBASIC Guide: 1.1 Run-Time 2.2 How to read the syntax 1.2 Loops and variables 3.5 The FILLED keyword w ired_gr.14 Nested procedures and functions 2.1 Constants and Variables 2.2 Useful notes for beginners 1.1 Unix script executables 2.

2 PalmOS (Typical 16bit system) E. GDBM Module D.1 Gereric E. Variable Index [Top ] [Contents ] [Index] [ ? ] w ired_gr.1.1 Interactive Mode Commands B.5 Statistics 9.1 2D & 3D graphics transformations 11. Limits D.2 File System Commands 9.6 Equations 10.2 Real Numbers E.3 Integer Numbers E. Glossary G.1 Supported console codes 12.3 Typical Module Makefile F. Command Index I.2 Round 9.1.1 Unit convertion 9.3 Trigonometry 9. Strings 12. Writting Modules E. Interactive Mode A.1 Typical 32bit system D.1 ADDENDUM: How to use this License for your documents H. Mathematics 9. 2D Algebra 10.1/15/13 SmallBASIC Guide: 6.net/doc/sb9/guide.1. File system 8. MySQL Module C.6 Graphics Commands 7.1 Variables API E.2 Console Commands A.users.5 Arrays E. Miscellaneous 8.4 Strings E.1.html#SEC44 87/89 .sourceforge. GNU Free Documentation License G.1 Special Device Names 8.4 Logarithms 9. Console 12.2 Typical Module Source E.1.

3 go to [Contents] Contents table of contents where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure: 1. Console A. Programming Tips 4.html#SEC44 <== Current Position . Limits E.1 Subsubsection One-Two-One 1.sourceforge. MySQL Module C.2. File system 9.2 Subsection One-Two 1.2.net/doc/sb9/guide.1/15/13 SmallBASIC Guide: Short Table of Contents 1. GDBM Module D. 2D Algebra 11. Commands 5.2. Variable Index [Top ] [Contents ] [Index] [ ? ] About this document This document was generated using texi2html The buttons in the navigation panels have the following meaning: Button [Top] [?] Name Top About Go to cover (top) of document this page From 1. Strings 12. System 6.. GNU Free Documentation License H.3 Subsubsection One-Two-Three w ired_gr. Graphics & Sound 7. 1. Writting Modules F. Miscellaneous 8.users.1 Subsection One-One .2 Subsubsection One-Two-Two 1. Mathematics 10. The language 3. Introduction 2. Section One 1. Interactive Mode B.2.. Glossary G. Command Index I.

1/15/13 SmallBASIC Guide: 1..users.net/doc/sb9/guide.4 Subsubsection One-Two-Four 1.4 Subsection One-Four This document was generated by root on May. 26 2004 using texi2html w ired_gr.sourceforge.html#SEC44 89/89 .3 Subsection One-Three .2. 1..

Sign up to vote on this title
UsefulNot useful