Small Basic Guide
Small Basic Guide
A Users Guide for SmallBASIC Edition Alpha, for SmallBASIC Version 0.9.0 August 2003.
Nicholas D. Christopoulos
Copyright c 2000, 2001, 2002, 2003, 2004 SmallBASIC Project. Copyright c 1991, 2004 Free Software Foundation, Inc.
This is Edition Alpha of SmallBASIC Guide: A Users Guide for SmallBASIC, for the 0.9.0 (or later) version of the SmallBASIC language. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being GNU General Public License, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled GNU Free Documentation License. a. A GNU Manual b. You have freedom to copy and modify this GNU Manual, like GNU software.
Table of Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Welcome to SmallBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 About BASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 About SmallBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.2 Cross-platform . . . . . . . . . . . . . . . . . . . . . . . . . Useful notes for beginners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 What we must already know . . . . . . . . . . . . . . . . . . . . . 1.2.2 How to read the syntax . . . . . . . . . . . . . . . . . . . . . . . . . Running SB Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running SB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 Unix script executables . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1 1 2 2 2 4 5 6 7
1.2
1.3 1.4
The language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1 Constants and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1.1 Variable names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1.2 About the dollar-symbol . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1.3 Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1.4 Reals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.5 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.6 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 System Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 The OPTION keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.5.1 Run-Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.5.2 Compile-Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Meta-commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Arrays and Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Nested arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 The operator IN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 The operator LIKE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 The pseudo-operator << . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Subroutines and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Single-line Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Nested procedures and functions . . . . . . . . . . . . . . . . . . . . . . . 18 Units (SB libraries) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 The pseudo-operators ++//p= . . . . . . . . . . . . . . . . . . . . . . . . . 20 The USE keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 The DO keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 2.15 2.16 2.17 2.18
ii
Programming Tips . . . . . . . . . . . . . . . . . . . . . . . . 22
3.1 3.2 3.3 Using LOCAL variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Loops and variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Loops and expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4 5 6
7 8
Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9.1 9.2 9.3 9.4 9.5 9.6 Unit convertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Round . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Trigonometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 50 51 52 52 53
10 11 12
2D Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.1 2D & 3D graphics transformations . . . . . . . . . . . . . . . . . . . . . . 55
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
12.1 12.2 Supported console codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Console Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
iii
E.2 E.3
Chapter 1: Introduction
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.
Chapter 1: Introduction
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 sucrice everything in the altar of simplicity. The world is full of languages, SB does not oers something new, but intents to oer 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 dierent platforms is an easy task. For this reason, SB claims that it is a cross-platform language. However, SB is based primary on Unix systems. A lot of feautures (for example, Units, C-Modules) does not implemented on other systems yet.
Chapter 1: Introduction
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 rst. 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 am a string.
String Constants String constants are the texts enclosed in double quotation marks, like this: "I am a string constant!" String Expressions String expressions are constructed from string variables, string constants, and function references using the operation for concatenation (+) to combine strings. Example: x = "HI" + " THERE!" 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 non-zero 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: Equal to (=), Not equal to (<>) Less than (<), Less than or equal to (<=) Greater than (>), Greater than or equal to (>=) 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 AND is true if both its left and right clauses are true. A logical expression using OR is true if either its left or its right, or both, clauses are true. A logical expression using NOT is 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.
Chapter 1: Introduction
Array Keyword
A grouping of multiple values under the same variable. 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 programspecic tasks. SB has a number of built-in procedures, and also allows you to dene your own. In older times those groups of statements was called routines. This is why the procedures are called SUB(routines) in BASIC. Function A specialized group of statements used to encapsulate general or programspecic tasks. SB has a number of built-in functions, and also allows you to dene your own. The dierence between function and procedure is that, function can return a value and can be used inside expressions. Procedure cant do that. The character generated by hitting the space bar on the keyboard. The character generated by hitting the TAB key on the keyboard. It usually expands to up to eight or four spaces upon output. A sequence of space, TAB, vertical tab, from-feed, or newline characters occurring inside an input record or a string. ...
Example #1:
Chapter 1: Introduction
<<<<<<-
is keyword is function is variable/parameter is array/parameter means that you must type A or B means that you must use A or B or nothing
Example #2: FOO a[, x] This means that you must give the rst parameter (a) but you can use the second (x) only if you want to. But if you want to use the (x) you must also separate it from (a) with a comma. Example #3: FOO var [{,|;} var2 [...]] This means that you must use the rst parameter. You can also use second parameter but you must separate it with , or ;. You can also repeat the last syntax more times The following code respects this syntax FOO FOO FOO FOO FOO FOO a a, a; a, a, a;
b b b; c b, c b; c, d; e, f, g
Example #4: Syntax: TEST {1|2} TEST 1 TEST 2 Syntax: TEST [HI] TEST TEST HI
Chapter 1: Introduction
# sbasic SmallBASIC VERSION 0.9.0 Copyright (c) 2000-2003 Nicholas Christopoulos Type HELP for help; type BYE or press Ctrl+C for exit. * READY *
/home/nikosc>
ENTER
Type the following program, pressing 10 PRINT "Are you ready" 20 PRINT "to learn BASIC?" 30 END
Check the program now to see if there are any typing mistakes. If there are, use up-arrow or down-arrow to nd the previously typed lines. Use right-arrow or left-arrow to move inside the line. Fix the problem and press ENTER . When you are ready to see the program in action, type CLS ENTER . The screen will be cleared.
Now, type RUN ENTER . /home/nikosc> run Are you ready to learn BASIC? * DONE * /home/nikosc>
/home/nikosc> list 10: PRINT "Are you ready" 20: PRINT "to learn BASIC?" 30: END /home/nikosc>
This is the simpliest way to run SB, usefull when we want to do some temporary calculations. It is also give us a taste of the old times.
1.4 Running SB
The usual way is type our program to an editor and save that in a le. Typically an SB program le must be terminated with .sb or .bas. That helps the OS to understand the type of the le.
Chapter 1: Introduction
Create a le with an editor like joe, kate or EDIT. Give to them a name, for example myprog.sb. Type some commands like our previous example, save it and exit from the editor. Now, run SB by using the le-name as parameter.
The -q option tells to SB to be quite. There are also more advanced ways to run a program with SB. For example, type a program that prints out SB commands! myprog.sb PRINT "PRINT 3/4" Now, run it by using | (pipe) symbol.
We did something very simple. The rst sbasic runs the myprog.sb, this program prints out the PRINT 3/4 text. The second sbasic was execute the result of the rst sbasic which was the code PRINT 3/4.
2 The language
This chapter documents language structure.
2.1.3 Integers
This is the default data type. You can declare integers in decimal, hexadecimal, octal and binary form. x = 256 x = 0x100 Hexadecimal form 1 x = &h100 Hexadecimal form 2
2.1.4 Reals
Any number which out-bounds the limits or an integer or had decimal digits will be converted automatically to real. x = .25 x = 1.2 Reals can be also written by using scientic notation. 1E+2 or 1E-+2, 5E2, 2.6E-0.25, etc
2.1.5 Strings
Strings may be appended to one another using the + operator. b = "Hello, " + "world!"
2.1.6 Constants
Constant variables can be declared by using the keyword CONST CONST my_pi = 3.14
10
Graphics display, maximum x (width-1) Graphics display, maximum y (height-1) value Graphics display: bits per pixel (color resolution) Video RAM address (only on specic drivers) Current Working Directory Users home directory
2.3 Operators
Sorted by priority () Parenthesis +, ~ NOT or ! ^ *, /, \ % or MOD MDL +, = <> or != >, < =>, =< >=, <= IN LIKE Unary bitwise NOT Logical NOT (NOT false = true) Exponentiation Multiplication, Division, Integer Division Reminder (QB compatible: a=int(a), b=int(b), a-b*(a/b)) Modulus (a%b+b*(sgn(a)<>sgn(b))) Addition/Concatenation, Subtraction Equal Not Equal Less Than, Greater Than Less or Equal, Greater or Equal Less or Equal, Greater or Equal belongs to ... (see "The IN operator") Regular expression match (see "The LIKE operator") Logical AND Logical OR bitwise AND
11
bitwise OR bitwise bitwise bitwise bitwise bitwise bitwise EQV IMP XOR NAND NOR XNOR
$1 Pseudo operators. These operators are replaced by compiler with a command or an expression.
2.5.1 Run-Time
OPTION BASE lower-bound
[Statement] The OPTION BASE statement sets the lowest allowable subscript of arrays to lowerbound. The default is zero. The OPTION BASE statement 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.
12
In most cases the OPTION BASE must declared at rst lines of the program before any DIM declaration.
[Statement] Sets as default matching algorithm to (P)erl-(C)ompatible (R)egular (E)xpressions library or back to simple one. Matching-algorithm is used in LIKE and FILES.
PRCE works only in systems with this library and it must be linked with. Also, there is no extra code on compiler which means that SB compiles the pattern everytime it is used.
2.5.2 Compile-Time
OPTION PREDEF parameter
Sets parameters of the compiler. Where parameter QUITE Sets the quite ag (-q option) [Statement]
COMMAND cmdstr Sets the COMMAND$ string to cmdstr (useful for debug reasons) GRMODE [widthxheight[xbpp]] Sets the graphics mode ag (-g option) or sets the prefered screen resolution. Example: (Clie HiRes) OPTION PREDEF GRMODE 320x320x16 TEXTMODE Sets the text mode ag (-g- option) CSTR Sets as default string style the C-style special character encoding (\)
2.6 Meta-commands
#!...
Used by Unix to make source runs as a script executable [Macro] [Macro] Used internally to store the section name. Sections names are used at limited OSes like PalmOS for multiple 32kB source code sections. With a few words DO NOT USE IT! [Macro] Used to include a SmallBASIC source le into the current BASIC code
#sec: section-name
[Macro] Used to setup additional directories for searching for unit-les This meta does nothing more than to setting up the environment variable SB UNIT PATH. Directories on Unix must separated by :, and on DOS/Windows by ;
Examples
13
14
? A B C ?
There is a problem with 1 dimension arrays, because 1-dim arrays does not specify how SmallBASIC must see them. DIM A(3) | 1 2 3 | = A or | 1 | | 2 | = A | 3 | And because this is not the same thing. (ex. for multiplication) So the default is columns DIM A(3) or A(1,3) | 1 2 3 | = A For vertical arrays you must declare it as 2-dim arrays Nx1 DIM A(3,1) | 1 | | 2 | = A | 3 |
15
A set is composed of characters or ranges; a range looks like character hyphen character (as in 0-9 or A-Z). [0-9a-zA-Z ] is the minimal set of characters allowed in the [..] pattern construct. To suppress the special syntactic signicance of any of []*?!^-\, and match the character exactly, precede it with a \. ? ? ? ? "Hello" "Hello" "Hello" "Hello" LIKE LIKE LIKE LIKE "*[oO]" "He??o" "hello" "[Hh]*" : : : : REM REM REM REM TRUE TRUE FALSE TRUE
16
17
x=2 F x ? x:REM displays 1 You can use the symbol @ instead of BYREF. There is no dierence between @ and BYREF. SUB F(@x) x=1 END On a multi-section (PalmOS) applications sub/funcs needs declaration on the main section. #sec:Main declare func f(x) #sec:another section func f(x) ... end Use the LOCAL keyword for local variables. LOCAL creates variables (dynamic) at routines code. SUB MYPROC LOCAL N:REM LOCAL VAR N=2 ? N:REM displays 2 END N=1:REM GLOBAL VAR MYPROC ? N:REM displays 1 You can send arrays as parameters. When using arrays as parameters its better to use them as BYREF; otherwise their data will be duplicated in memory space. SUB FBR(BYREF tbl) ? FRE(0) ... END SUB FBV(tbl) ? FRE(0) ... END MAIN DIM dt(128) ... ? FRE(0)
18
FBR dt ? FRE(0) FBV dt ? FRE(0) Passing & returning arrays, using local arrays. func fill(a) local b, i dim b(16) for i=0 to 16 b(i)=16-a(i) next fill=b end DIM v() v=fill(v)
19
FUNC f3 f3=f1(pi/2) END REM ? f1(pi) : REM OK ? f2(pi) : REM ERROR f = x + f1(pi) + f3 : REM OK END
20
F = x*x END REM a non-shared function FUNC I(x) I = x+x END REM Initialization code V="I am a shared variable" L="I am invisible to the application" PRINT "Unit MyUnit initialized :)" le my app.bas: IMPORT MyUnit PRINT MyUnit.V PRINT MyUnit.F(2)
21
22
3 Programming Tips
Programmers must use clean and logical code. Weird code may be faster but it is not good.
23
UNTIL i > 10 Initializing the variables at the top of the loop, can make code better readable, and can protect us from usual pitfalls such as forgeting to giving init value or re-run the loop without reset the variables.
Chapter 4: Commands
24
4 Commands
REM comment
[Statement] Adds explanatory text to a program listing. comment commentary text, ignored by BASIC. Instead of the keyword we can use the symbol or the #. The # can be used as remarks only if its in the rst character of the line. Example: That text-line is just a few remarks ... REM another comment ... # one more comment [Statement] A valid variable name. The value assigned to variable. x = 4 1 "String data" v(4) Assign array (z = clone of v) [Statement] Assigns the value of an expression to a variable. The LET is optional. var expr Example: LET x = z = ... DIM z=v
An identier that follows the rules for naming BASIC variables. An expression consisting of literals, with or without operators, only.
[Statement] The DIM statement reserves space in computers memory for arrays. The array will have (upper-lower)+1 elements. If the lower is not specied, and the OPTION BASE hasnt used, the arrays are starting from 0. Example: REM One dimension array of 7 elements, starting from 0 DIM A(6) ... REM One dimension array of 6 elements, starting from 1 DIM A(1 TO 6)
Chapter 4: Commands
25
... REM Three dimension array DIM A(1 TO 6, 1 TO 4, 1 TO 8) ... REM Allocating zero-length arrays: DIM z() ... IF LEN(Z)=0 THE APPEND Z, "The first element"
LABEL name
Denes a label. A label is a mark at this position of the code. There are two kinds of labels, the numeric and the alphanumeric.
[Statement]
Numeric labels does not needed the keyword LABEL, but alphanumeric does. Example: 1000 ? "Hello" ... LABEL AlphaLabel: ? "Hello" ... GOTO 1000 GOTO AlphaLabel
GOTO label
Causes program execution to branch to a specied position (label).
[Statement]
GOSUB label
[Statement] Causes program execution to branch to the specied label; when the RETURN command is encountered, execution branches to the command immediately following the most recent GOSUB command. [Statement] Execution branches to the command immediately following the most recent GOSUB command. ... GOSUB my_routine PRINT "RETURN sent me here" ... LABEL my_routine PRINT "I am in my routine" RETURN
RETURN
[Statement]
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).
Chapter 4: Commands
26
[Statement]
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. FOR/NEXT loops may be nested to any level of complexity, but there must be a NEXT for each FOR. Example: FOR C=1 TO 9 PRINT C NEXT
[Statement]
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] FOR E IN A PRINT E NEXT ... This is the same with that A=[1,2,3] FOR I=LBOUND(A) TO UBOUND(A) E=A(I) PRINT E NEXT
Chapter 4: Commands
27
[Statement]
BASIC starts by evaluating expression. If expression is nonzero (true), the next command is executed. If expression is zero (false), control passes to the rst command following the next WEND command. When BASIC encounters the WEND command, it reevaluates the expression parameter to the most recent WHILE. 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 WHILE C<10 PRINT C C=C+1 WEND ... This is the same with that FOR C=1 TO 9 PRINT C NEXT
[Statement]
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 REPEAT PRINT C C=C+1 UNTIL C=10 ... This is the same with that FOR C=1 TO 9 PRINT C NEXT
Chapter 4: Commands
28
IF ...
Syntax: IF expression1 [THEN] . . [commands] . [ [ELSEIF | ELIF] expression2 [THEN] . . [commands] . ] [ELSE . . [commands] . ] { ENDIF | FI } Block-style IF. Causes BASIC to make a decision based on the value of an expression.
[Statement]
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 specied, then execution continues with the command following the ENDIF. IF, ELSE, ELSEIF, and ENDIF must all be the rst keywords on their respective lines. THEN is optional, but if its dened it must be the last keyword on its line; if anything other than a comment follows on the same line with THEN, BASIC thinks its reading a single-line IF/THEN/ELSE construct. IF blocks may be nested. Example: x=1 IF x=1 THEN PRINT "true" ELSE PRINT "false" ENDIF ... Alternate syntax: x=1
Chapter 4: Commands
29
IF x=1 PRINT "true" ELSE PRINT "false" FI Single-line IF. Syntax: IF expression THEN [num-label]|[command] [ELSE [num-label]|[command]] 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. command Example: Single-line IF x=1 IF x=1 THEN PRINT "true" ELSE PRINT "false" ... IF x=1 THEN 1000 ... 1000 PRINT "true" Any legal command or a numeric label. If a number is specied, it is equivalent to a GOTO command with the specied numeric-label.
[Function]
[Statement] [Statement] Terminates execution of a program, closes all les opened by the program, and returns control to the operating system. error A numeric expression.
The error is the value which will returned to operating system; if its not specied the BASIC will return 0. DOS/Windows The error value is very well known as ERRORLEVEL value.
RESTORE label
Species the position of the next data to be read. label A valid label.
[Statement]
Chapter 4: Commands
30
[Command]
Unless a RESTORE command is executed, BASIC moves to the next DATA item with each READ assignment. If BASIC runs out of DATA items to READ, an run-time error occurs. Example: FOR c=1 TO 6 READ x PRINT x NEXT ... DATA "a,b,c", 2 DATA 3, 4 DATA "fifth", 6
[Statement] Stores one or more constants, of any type, for subsequent access via READ command.
DATA commands are nonexecutable statements that supply a stream of data constants for use by READ commands. 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 programs READ commands. Example: RESTORE MyDataBlock FOR I=1 TO 3 READ v PRINT v NEXT END ... LABEL MyDataBlock DATA 1,2,3
[Statement]
Deallocates the memory used by the specied arrays or variables. After that these variables turned to simple integers with zero value. Example: DIM x(100) ... PRINT FRE(0) ERASE x PRINT FRE(0) PRINT x(1):REM ERROR
Chapter 4: Commands
31
EXIT [FOR|LOOP|SUB|FUNC]
[Statement] Exits a multiline function denition, a loop, or a subprogram. By default (if no parameter is specied) exits from last command block (loop, for-loop or routine). FOR LOOP SUB FUNC Exit from the last FOR-NEXT loop Exit from the last WHILE-WEND or REPEAT-UNTIL loop Return from the current routine Return from the current function [Function] Any variable.
LEN (x)
x
If x is a string, returns the length of the string. If x is an array, returns the number of the elements. If x is an number, returns the length of the STR(x).
EMPTY (x)
x Any variable.
[Function]
If x is a string, returns true if the len(x) is 0. If x is an integer or a real returns true if the x = 0. If x is an array, returns true if x is a zero-length array (array without elements).
ISARRAY (x)
x Any variable. Returns true if the x is an array.
[Function]
ISNUMBER (x)
x Any variable. (or it can be converted to a number) :REM :REM :REM :REM :REM :REM true true true false false false Returns true if the x is a number Example: ? ISNUMBER(12) ? ISNUMBER("12") ? ISNUMBER("12E+2") ? ISNUMBER("abc") ? ISNUMBER("1+2") ? ISNUMBER("int(2.4)")
[Function]
ISSTRING (x)
x Any variable. Returns true if the x is a string (and cannot be converted to a number) Example: ? ISSTRING(12) :REM false ? ISSTRING("12") :REM false ? ISSTRING("12E+2") :REM false ? ISSTRING("abc") :REM true ? ISSTRING("1+2") :REM true
[Function]
Chapter 4: Commands
32
[Command]
[Command]
[Command]
Chapter 5: System
33
5 System
FRE (x)
Returns system information Where x: QB-standard: 0 -1 -2 -3 -10 -11 -12 -13 -14 -15 -16 -17 -18 -40 -41 -42 -43 free memory largest block of integers free stack largest free block total physical memory used physical memory free physical memory shared memory size buers cached total virtual memory size used virtual memory free virtual memory battery voltage * 1000 battery percent critical voltage value (*1000) warning voltage value (*1000) [Function]
Optional-set #1:
Optional-set #2:
[Command] Creates a Run-Time-Error. The parameters will be displayed on error-line. [Function] Returns the system-ticks. The tick value is depended on operating system. [Function] [Function] [Function] [Command] Returns the number of ticks per second
TICKSPERSEC TIMER
Returns the number of seconds from midnight
TIME
Returns the current time as string "HH:MM:SS"
Chapter 5: System
34
DATE
Returns the current day as string "DD/MM/YYYY"
[Function] [Function]
[Command] [Function]
[Function]
DELAY ms
[Command] Delay for a specied amount of milliseconds. This delay is also depended to system clock. [Command] Sorts an array. The cmpfunc (if its specied) it takes 2 vars to compare. cmpfunc must returns -1 if x < y, +1 if x > y, 0 if x = y FUNC qscmp(x,y) IF x=y qscmp=0 ELIF x>y qscmp=1
Chapter 5: System
35
ELSE qscmp=-1 ENDIF END ... DIM A(5) FOR i=0 TO 5 A(i)=RND NEXT SORT A USE qscmp(x,y)
[Command] Scans an array for the key. If key is not found the SEARCH command returns (in ridx) the value (LBOUND(A)-1). In default-base arrays that means -1. The cmpfunc (if its specied) it takes 2 vars to compare. It must return 0 if x = y; non-zero if x <> y FUNC cmp(x,y) cmp=!(x=y) END ... DIM A(5) FOR i=0 TO 5 A(i)=5-i NEXT SEARCH A, 4, r USE cmp(x,y) PRINT r:REM prints 1 PRINT A(r): REM prints 4
CHAIN le
[Command] Transfers control to another SmallBASIC program. le - A string expression that follows OS le naming conventions; The le must be a SmallBASIC source code le. CHAIN "PROG2.BAS" [Command] Transfers control to another program This routine works like CHAIN with the exception the le can be any executable le. EXEC never returns [Command] [Command] Adds a variable to or deletes a variable from the current environment variable-table. expr A string expression of the form "name=parameter"
EXEC le
If name already exists in the environment table, its current setting is replaced with the new setting. If name does not exist, the new variable is added. PalmOS SB emulates environment variables.
Chapter 5: System
36
[Function] [Function] Returns the value of a specied entry in the current environment table. 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"
RUN cmdstr
[Command] Loads a secondary copy of systems shell and, executes an program, or an shell command. cmdstr Shells specic command string
After the specied shell command or program terminates, control is returned to the line following the RUN command. PalmOS The cmdstr is the Creator-ID. PalmOS The RUN never returns.
RUN ("command")
[Function] RUN() is the function version of the RUN command. The dierence is that, 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. Windows The stdout and stderr are separated! First is the stdout output and following the stderr.
TRON TROFF
[Command] [Command] TRACE ON/OFF. When trace mechanism is ON, the SB displays each line number as the program is executed [Command] PRINT to SBs logle. The syntax is the same with the PRINT command. [Function] [Function]
LOGPRINT ...
VADR (var)
Returns the memory address of the variables data.
[Function] [Function]
PEEK[{16|32}] (addr)
Returns the byte, word or dword at a specied memory address.
Chapter 5: System
37
[Command] [Command]
USRCALL addr
Transfers control to an assembly language subroutine. The USRCALL is equal to: void (*f)(void); f = (void (*)(void)) addr; f();
STKDUMP
Displays the SBs internal executors stack * For debug purposes; it is not supported on "limited" OSes.
38
39
[Command]
[Command]
[Command] [Command]
If the array does not uses points as element arrays, then even elements for x (starting from 0), odd elements for y
DRAW string
Draws an object according to instructions specied as a string.
[Command]
string - A string expression containing commands in the BASIC graphics denition language. Graphics Denition Language In the movement instructions below, n species a distance to move. The number of pixels moved is equal to n multiplied by the current scaling factor, which is set by the S command. Un Dn Ln Rn Move Move Move Move up. down. left. right.
40
En Fn Gn Hn Mx,y B N
Move diagonally up and right. Move diagonally down and right. Move diagonally down and left. Move diagonally up and left. Move to coordinate x,y. If x is preceded by a + or -, the movement is relative to the last point referenced. A prex command. Next movement command moves but doesnt plot. A prex command. Next movement command moves, but returns immediately to previous point.
* This command it is had not tested - please report any bug or incompatibility.
[Command] [Command] [Command] [Function] [Function] [Function] [Function] [Function] [Function] [Function]
XPOS YPOS
Returns the current position of the cursor in "characters".
POINT (x [, y])
Returns the color of the pixel at x,y if y does not specied x contains the info-code 0 = returns the current X graphics position 1 = returns the current Y graphics position
[Command]
Screen coordinate (column, row) within the area that is to be lled. The ll-color The boundary-color
41
if the border-color is specied then the PAINT will ll all the area which is specied by the border-color. (ll-until, color!=point(x,y) if the border-color is NOT specied then the PAINT will ll all the are with the same color as the pixel at x,y. (ll-while, color=point(x,y))
[Command]
Corner coordinates of the viewport. If included, BASIC lls the viewport with the specied color.
border-color If included, BASIC draws a border, in a specied color, around the dened viewport. The viewport dened by VIEW is disabled by a VIEW command with no parameters.
WINDOW [x1,y1,x2,y2]
Species "world" coordinates for the screen. x1 y1 x2 y2
[Command]
The WINDOW command allows you to redene the corners of the display screen as a pair of "world" coordinates. The world space dened by WINDOW is disabled by a WINDOW command with no parameters.
RGB (r, g, b)
[Function] The RGB functions returns the RGB color codes for the specied values The RGB() takes values 0..255 for each of the color. The return value is a negative 24bit value to by used by drawing functions. [Function] The RGBF functions returns the RGB color codes for the specied values The RGBF() takes values 0..1 for each of the color. The return value is a negative 24bit value to by used by drawing functions. [Command] [Command] Generates a beep sound
RGBF (r, g, b)
42
Octave 0..6, < moves down one octave, > moves up one octave Play note 0..84 (0 = pause) Pause 1..64 Length of note 1..64 (1/nnn) Tempo 32..255. Number of 1/4 notes per minute. Staccato (1/2) Normal (3/4) Legato Volume 0..100 Play on foreground Play on background Clear sound queue [Command]
NOSOUND
Stops background sound. Also, clears the sound queue.
[Command]
Chapter 7: Miscellaneous
43
7 Miscellaneous
RANDOMIZE [int]
Seeds the random number generator [Command] [Function] [Function] [Function]
RND
Returns a random number from the range 0 to 1
CINT (x)
Converts x to 32b integer Meaningless. Used for compatibility.
CREAL (x)
Convert x to 64b real number. Meaningless. Used for compatibility.
CDBL (x)
Convert x to 64b real number. Meaningless. Used for compatibility.
PEN ON|OFF
Enables/Disables the PEN/MOUSE mechanism.
PEN (0..14)
Returns the PEN/MOUSE data. Values: 0 1 2 3 4 5 true (non zero) if there is a new pen or mouse event PEN: last pen down x; MOUSE: last mouse button down x Same as 1 for y
true if the PEN is down; MOUSE: mouse left button is pressed PEN: last/current x, MOUSE: the current x position only if the left mouse button is pressed (like PEN is down) Same as PEN(4) for y
Chapter 7: Miscellaneous
44
Mouse specic (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] Pauses the execution for a specied length of time, or until user hit the keyboard.
[Command] Exchanges the values of two variables. The parameters may be variables of any type.
45
8 File system
8.1 Special Device Names
"COM1:[speed]" Serial port 1 "COM2:[speed]" Serial port 2 "PDOC:filename" Compressed PDOC les for PalmOS or PDB/PDOC les on other systems. PDOCFS opens and uncompress the le on OPEN; and compress the le on CLOSE. So, it will use a lot of memory and time (its depended on size of the data). "MEMO:memo-title" MemoDB of PalmOS or regular le on other systems. Memo records (virtual les) are limited to 3935 bytes "SOCL:server:port" Socket client. Actually a telnet client. "MMC:filename" eBookMan only. Opens an MMC le. Example: OPEN "COM1:" AS #1 OPEN "COM2:38400" AS #2
CLOSE #leN
Close a le or device
[Command]
46
[Command]
[Command]
An array variable or a string variable. Expressions are not allowed for memory reasons. [Function] A string expression that follows OS le naming conventions. [Function] A string expression that follows OS le naming conventions.
EXIST (le)
Returns true if the le exists le
ACCESS (le)
Returns the access rights of the le. le
The return-value is the permissions of the le as them as specied on GNUs manual (chmod() and stat() system calls) The bits (in octal): 04000 02000 01000 00400 00200 00100 00040 00020 00010 00004 00002 00001 set user ID on execution set group ID on execution sticky bit read by owner write by owner execute/search by owner read by group write by group execute/search by group read by others write by others execute/search by others
PalmOS The return value is always 0777. DOS The return value is depended on DJGPPs stat() function. Possible Unix compatible. Windows The return value is depended on Cygnuss stat() function. Possible Unix compatible. IF ACCESS("/bin/sh") AND 0o4 THEN PRINT "I can read it!" ENDIF
47
ISFILE (le)
Returns true if the le is a regular le.
ISDIR (le)
Returns true if the le is a directory.
ISLINK (le)
Returns true if the le is a link.
The mode is compatible with the chmod()s mode parameter as its described on GNUs manual. See ACCESS() for more information. Make myfile available to anyone (read/write) CHMOD "myfile.bas", 0o666 ... Make myfile available to anyone (execute/read/write) CHMOD "myfile.bas", 0o777
EOF (leN)
[Function] Returns true if the le pointer is at end of the le. For COMx and SOCL VFS it returns true if the connection is broken. [Command] Write string to a le. The syntax is the same with the PRINT command. * We can use USG instead of USING.
LINPUT# [leN{,|;}] var LINEINPUT# [#leN{,|;}] var LINE INPUT# [leN{,|;}] var
Reads a whole text line from le or console.
[Function] This function is similar to INPUT. Reads len bytes from le or console (if leN is omitted). This function is a low-level function. That means does not convert the data, and does not remove the spaces. [Command] [Function] [Command] [Command] Reads data from le
48
SEEK (leN)
Returns the current le position
[Function]
LOF (leN)
[Function] Returns the length of le in bytes. For other devices, it returns the number of available data. [Command]
KILL "le"
Deletes the specied le
[Command] [Command] The READ/WRITE command set is used to store variables to a le as binary data. The common problem with INPUT/PRINT set is there are many conicts with data. PRINT #1; "Hello, world" You have wrote only one string and you want read it in one variable, but this is impossible for INPUT command to understand it, because INPUT nds the separator comma, so it thinks there are two variables not one. So, now, you can store arrays, strings etc and what is you write is what you will read the next time. BTW its faster too. * The parameters can be variables ONLY. * Its very bad idea to mixed READ/WRITE commands with INPUT/PRINT commands in the same le.
MKDIR dir
Create a directory. This does not working on PalmOS.
CHDIR dir
[Command] Changes the current working directory. This does not working on PalmOS. [Command] Removes a directory. This does not working on PalmOS.
[Command] Walk through the directories. The user-dened function must returns zero to stop the process. FUNC PRNF(x) ? x PRNF=TRUE END
49
FILES (wildcards)
[Function] Returns an array with the lenames. If there is no les returns an empty array. ? FILES("*")
PalmOS Returns only the user-les. * To use le on MEMO or PDOC or any other virtual le system you must use FILES("VFSx:*") PRINT FILES("MEMO:*")
Chapter 9: Mathematics
50
9 Mathematics
All angles are in radians.
ABS (x)
Returns the absolute value of x.
[Function]
[Function] [Function] [Function] [Function] Maximum/Minimum value of parameters. Parameters can be anything (arrays, ints, reals, strings). ABSMIN/ABSMAX returns the absolute min/max value. ? MAX(3,4,8) ? MIN(array(),2,3) ? MAX("abc","def")
[Function] Returns an array with count elements. Each element had the x value of its position. ? SEQ(0,1,11)
[Command] Returns an array with count elements. Each element had the y value of its position as it is returned by the expression. REM same as v=SEQ(0,1,11) EXPRSEQ v, 0, 1, 11 USE x
POW (x, y)
x raised to power of y
[Function]
SQR (x)
Square root of x
[Function]
SGN (x)
Sign of x (+1 for positive, -1 for negative and 0 for zero)
[Function]
RAD (x)
Degrees to radians
[Function]
Chapter 9: Mathematics
51
9.2 Round
INT (x)
Rounds x downwards to the nearest integer [Function] [Function] [Function] [Function] [Function] [Function]
FIX (x)
Rounds x upwards to the nearest integer
FLOOR (x)
Largest integer value not greater than x
CEIL (x)
Smallest integral value not less than x
FRAC (x)
Fractional part of x
ROUND (x [, decs])
Rounds the x to the nearest integer or number with decs decimal digits.
9.3 Trigonometry
COS (x)
Cosine [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function]
SIN (x)
Sine
TAN (x)
Tangent
ACOS (x)
Inverse cosine
ASIN (x)
Inverse sine
ATAN2 (x, y)
Inverse tangent (x,y)
Chapter 9: Mathematics
52
[Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function]
CSC (x)
Cosecant
COT (x)
Cotangent
ASEC (x)
Inverse secant
ACSC (x)
Inverse cosecant
ACOT (x)
Inverse cotangent
SECH (x) CSCH (x) COTH (x) ASECH (x) ACSCH (x) ACOTH (x)
9.4 Logarithms
EXP (x)
Returns the value of e raised to the power of x. [Function] [Function] [Function]
LOG (x)
Returns the natural logarithm of x.
LOG10 (x)
Returns the base-10 logarithm of x.
9.5 Statistics
Sample standard deviation: SQR(STATSPREADS(array)) Population standard deviation: SQR(STATSPREADP(array))
SUM (...)
Sum of value
[Function]
Chapter 9: Mathematics
53
SUMSQ (...)
Sum of square value
STATMEAN (...)
Arithmetical mean
STATMEANDEV (...)
Mean deviation
STATSPREADS (...)
Sample spread
STATSPREADP (...)
Population spread
9.6 Equations
LINEQN (a, b [, toler])
[Function] Returns an array with the values of the unknowns. This function solves equations by using the Gauss-Jordan method. b b toler equations results tolerance number. (the absolute value of the lowest acceptable number) default = 0 = none... |x| <= toler : x = 0
* The result is a matrix Nx1. For the SB that array is two-dimension array.
INVERSE (A)
returns the inverse matrix of A.
[Function]
[Function] Determinant of A toler = tolerance number (the absolute value of the lowest acceptable number) default = 0 = none |x| <= toler : x = 0 [Command]
ROOT low, high, segs, maxerr, BYREF result, BYREF errcode USE
expr Roots of F(x) low high segs maxerr the lower limit the upper limit the number of segments (spaces) tolerance (IF ABS(F(x)) < maxerr THEN OK)
Chapter 9: Mathematics
54
errcode result
the result FUNC F(x) F = SIN(x) END ... ROOT 1, 5, 500, 0.00001, result, errcode USE F(x) [Command]
DIFFEQN x0, y0, xf, maxseg, maxerr, BYREF yf, BYREF errcode
USE expr Dierential equation - Runge-Kutta method x0 y0 xf maxseg maxerr errcode yf initial x,y x nal maximum number of segments on x tolerance (acceptable error between the last 2 times) 0 for success; otherwise calculation error the result
[Command]
55
10 2D Algebra
SEGCOS (Ax,Ay,Bx,By,Cx,Cy,Dx,Dy) SEGSIN (Ax,Ay,Bx,By,Cx,Cy,Dx,Dy)
Sinus or cosine of 2 line segments (A->B, C->D). [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Command]
PTDISTSEG (Bx,By,Cx,Cy,Ax,Ay)
Distance of point A from line segment B-C
PTDISTLN (Bx,By,Cx,Cy,Ax,Ay)
Distance of point A from line B, C
PTSIGN (Ax,Ay,Bx,By,Qx,Qy)
The sign of point Q from line segment A->B
SEGLEN (Ax,Ay,Bx,By)
Length of line segment
POLYAREA (poly)
Returns the area of the polyline poly.
INTERSECT Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, BYREF type, BYREF
Rx, BYREF Ry Calculates the intersection of the two line segments A-B and C-D Returns: Rx,Ry = cross type = cross-type 0 1 2 3 4 No cross (R = external cross) One cross Parallel Parallel (many crosses) The cross is one of the line segments edges.
[Command]
[Command]
56
[Command]
[Command]
[Command]
[Command]
| -1 | 0 | 0 | | | | 1 0 0 0
3D-Graphics Matrices:
| Sx 0 0 | 0 Sy 0 | 0 0 Sz | 0 0 0 | | | | | | 1 0 0 0 c 0 0 0 c -s s c 0 0 0 1 s 0
0 | 0 | = rotation on y
57
| -s | 0
0 0
c 0
0 | 1 |
| c -s 0 0 | | s c 0 0 | = rotation on z | 0 0 1 0 | | 0 0 0 1 | Any change to matrix will combined with its previous value. DIM poly(24) DIM M(2,2) ... M3IDENT M M3ROTATE M, pi/2, 0, 0 M3SCALE M, 0, 0, 1.24, 1.24 ... Draw the original polyline DRAWPOLY poly ... Draw the polyline rotated by pi/2 from 0,0 and scaled by 1.24 M3APPLY M, poly DRAWPOLY poly
58
11 Strings
SPC (n) SPACE (n)
returns a string of n spaces [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function] [Function]
BIN (x)
Returns the binary value of x as string.
OCT (x)
Returns the octal value of x as string.
HEX (x)
Returns the hexadecimal value of x as string.
VAL (s)
Returns the numeric value of string s.
STR (x)
Returns the string value of x.
* On CBS() we cannot use the " character but we can replace it with x22 or 042.
ASC (s)
Returns the ASCII code of rst character of the string s.
CHR (x)
Returns one-char string of character with ASCII code x.
LTRIM (s)
Removes leading white-spaces from string s ? LEN(LTRIM(" Hi")):REM 2
[Function]
RTRIM (s)
Removes trailing white-spaces from string s
[Function]
59
TRIM (s)
Removes leading and trailing white-spaces from string s. LTRIM(RTRIM(s))
SQUEEZE (s)
Removes the leading/trailing and duplicated white-spaces ? "["; SQUEEZE(" Hi there "); "]" Result: [Hi there]
[Function]
[Function]
[Function]
Otherwise: " s ? s ? s ?
""
= "abc (abc)" s; tab(26); disclose(s, "()") prints abc = "abc (a(bc))" s; tab(26); disclose(s, "()"); tab(40); disclose(disclose(s, "()"), "()") prints a(bc), bc = "abc (a=(bc))" s; tab(26); disclose(s, "()", ""); tab(40); & disclose(disclose(s, "()", ""), "()", "") prints a=(bc), nothing
[Function] [Function] Returns the n number of leftmost/rightmost chars of string s If n is not specied, the SB uses 1
60
[Function] [Function] Returns the left/right part of s1 at the position of the rst occurrence of the string s2 into string s1 * s2 does not included on new string.
[Function] [Function] 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.
[Function]
If the length parameter is omitted, MID returns the whole string from the position start.
[Function] Returns the position of the rst occurrence of the string s2 into string s1 (starting from the position start) If there is no match, INSTR returns 0
[Function] Returns the position of the last occurrence of the string s2 into string s1 (starting from the position start) If there is no match, RINSTR returns 0
[Function]
This function replaces only len characters. The default value of len is the length of str. s="123456" ... Cut ? replace(s,3,"",len(s)) ... Replace ? replace(s,2,"bcd") ... Insert ? replace(s,3,"cde",0) ... Replace & insert ? replace(s,2,"RRI",2)
61
[Function] Translates all occurrences of the string what found in the source with the string with and returns the new string. ? Translate("Hello world", "o", "O") displays: HellO wOrld
CHOP (source)
Chops o the last character of the string source and returns the result.
[Function]
[Function] Returns a string containing len times of string str or the character ascii. [Function] Returns a formated string. Numbers: # 0 ^ . , + Strings: & ! \\ Stores a string expression without reformatting it. Stores only the rst character of a string expression. Stores only the rst n + 2 characters of a string expression, where n is the number of spaces between the two backslashes. Unlike QB, there can be literals inside the \ \. These literals are inserted in the nal string. ? FORMAT("#,##0", 1920.6) : REM prints 1,921 ? FORMAT("\ - \", "abcde") : REM prints "abc-de" Digit or space Digit or zero Stores a number in exponential format. Unlike QBs USING format this is a place-holder like the #. The position of the decimal point. Separator. Stores minus if the number is negative. Stores the sign of the number.
[Command] Create formated string and storing it to var The syntax is the same with the PRINT command. SPRINT s; 12.34; TAB(12); 11.23;
[Command]
62
SINPUT "if x>1 then y"; vif, " ", vcond, "then", vdo ? vcond, vdo result in monitor x>1 y
[Command]
[Command]
63
12 Console
* e = CHR(27) \t \a \r\n \xC \e[K \e[nG \e[0m \e[1m \e[4m \e[7m \e[21m \e[24m \e[27m \e[3nm tab (32 pixels) beep new line (cr/lf) clear screen clear to EOL moves cursor to specied column reset all attributes to their defaults set bold on set underline on reverse video set bold o set underline o set reverse o set foreground color. where n: 0 1 2 3 4 5 6 7 \e[4nm PalmOS only: \e[8nm \e[9nm eBookMan only: \e[50m \e[51m \e[52m \e[nT select 9pt font select 12pt font select 16pt font move to n/80th screen character position (n=0..7) select system font (n=0..3) select buildin font black red green brown blue magenta cyan white
64
The PRINT USING Print USING, is using the FORMAT() to display numbers and strings. Unlike the FORMAT, this one can include literals, too. Print next character as a literal. The combination #, for example, allows you to include a number sign as a literal in your numeric format. [other] literals in the format string.
* When a PRINT USING command is executed the format will remains on the memory until a new format is passed. Calling a PRINT USING without a new format specied the PRINT will use the format of previous call. Examples: PRINT USING "##: #,###,##0.00"; FOR i=0 TO 20 PRINT USING; i+1, A(i) NEXT .... PRINT USING "Total ###,##0 of \ \"; number, "bytes" * The symbol ? can be used instead of keyword PRINT You can use USG instead of USING.
CAT (x)
Returns a console codes 0 1 -1 2 -2 3 -3 reset bold on bold o underline on underline o reverse on reverse o
[Function]
65
PalmOS only: 80..87 select system font 90..93 select custom font Example: ? cat(1);"Bold";cat(0)
INKEY
[Function] This function returns the last key-code in keyboard buer, or an empty string if there are no keys. Special key-codes like the function-keys (PC) or the hardware-buttons (PalmOS) are returned as 2-byte string. Example: k=INKEY IF LEN(k) IF LEN(k)=2 ? "H/W #"+ASC(RIGHT(k,1)) ELSE ? k; " "; ASC(k) FI ELSE ? "keyboard buffer is empty" FI [Command] Clears the screen. [Command]
CLS AT x, y
Moves the console cursor to the specied position. x,y are in pixels
LOCATE y, x
[Command] Moves the console cursor to the specied position. x,y are in character cells.
66
[Command] [Command] [Command] The BYE command ends SmallBASIC and returns the control to the Operating System. [Command] The NEW command clears the memory and screen and prepares the computer for a new program. 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. [Command] The RUN command, which can also be used as a statement, starts program execution. [Command] Clears the screen. [Command] The LIST command allows you to display program lines. If LIST is entered with no numbers following it, the entire program in memory is listed. If a number follows the LIST, the line with that number is listed. If a number followed by hyphen follows LIST, that line and all lines following it are listed. If a number preceeded by a hyphen follows LIST, all lines preceeding it and that line are listed. If two numbers separated by a hyphen follow LIST, the indicated lines and all lines between them are listed.
NEW
67
[Command]
[Command] The ERA command allows you to erase program lines. If ERA is entered with no numbers following it, the entire program in memory is erased. If a number follows the ERA, the line with that number is erased. If a number followed by hyphen follows ERA, that line and all lines following it are erased. If a number preceeded by a hyphen follows ERA, all lines preceeding it and that line are erased. If two numbers separated by a hyphen follow ERA, the indicated lines and all lines between them are erased. [Command] The NUM command sets the values for the autonumbering. If the initial-line and increment are not specied, the line numbers start at 10 and increase in increments of 10. [Command] The SAVE command allows you to copy the program in memory to a le. By using the LOAD command, you can later recall the program into memory. [Command] The LOAD command loads program-name le into memory. The program must rst have been put on le using the SAVE command. LOAD removes the program currently in memory before loading program-name. [Command] The MERGE command merges lines in program-name le into the program lines already in the computers memory. Use line-number to specify the position where the lines will be inserted. [Command] Changed the current directory. Without arguments, displays the current directory.
SAVE program-name
LOAD program-name
CD [path]
[Command] [Command] [Command] [Command] Displays the list of les. You can use DIRE for executables only or DIRD for directories only, or DIRB for BASIC sources. [Command]
TYPE lename
Displays the contents of the le.
68
MYSQL.DBS (handle)
Get a list of the databases
MYSQL.TABLES (handle)
Get a list of the tables
MYSQL.DISCONNECT handle
Disconnects
h = mysql.connect("localhost", "mydatabase", "user", "password") ? "Handle = "; h ? "DBS = "; mysql.dbs(h) ? "TABLES = "; mysql.tables(h) ? "Query = "; mysql.query(h, "SELECT * FROM sbx_counters") mysql.disconnect h
69
TEST h = gdbm.open("dbtest.db", 512, GDBM_WRCREAT, 0o666) ? "Handle = "; h ? "Store returns = "; gdbm.store(h, "key1", "data1....") ? "Store returns = "; gdbm.store(h, "key2", "data2....") ? "Fetch returns = "; gdbm.fetch(h, "key1") gdbm.close h
Appendix D: Limits
70
Appendix D Limits
D.1 Typical 32bit system
Bytecode size 4 GB Length of text lines 4095 characters User-dened keyword length 128 characters Maximum number of parameters 256 Numeric value range 64 bit FPN (-/+ 1E+308) Maximum string size 2 GB Number of le handles 256 Number of array-dimensions 6 Number of colors 24 bit (0-15=VGA, <0=RGB) Background sound queue size 256 notes INPUT (console) 1023 characters per call, up to 16 variables COMMAND$ 1023 bytes System events are checked every 50ms
71
72
/* * Displays variable data. * If the variable is an array, then this function * runs recursive, and the level parameter is used. */ static void print_variable(int level, var_t *variable) { int i; /* if recursive; place tabs */ for ( i = 0; i < level; i ++ ) dev_printf("\t"); /* print variable */ switch ( variable->type ) { case V_STR: dev_printf("String =\"%s\"\n", variable->v.p.ptr); break; case V_INT: dev_printf("Integer = %ld\n", variable->v.i); break; case V_REAL: dev_printf("Real = %.2f\n", variable->v.n); break; case V_ARRAY: dev_printf("Array of %d elements\n", variable->v.a.size); for ( i = 0; i < variable->v.a.size; i ++ ) { var_t *element_p; element_p = (var_t *) (variable->v.a.ptr + sizeof(var_t) * i); print_variable(level+1, element_p); } break; } }
E.1.1 Gereric
void v free(var t *var) This function resets the variable to 0 integer. void v free(var t *var) This function deletes the contents of varible var. var t* v new() Creates a new variable and returns it. The returned variable it must be freed with both, v free() and free() functions.
73
var t *v clone(const var t *source) Returns a new variable which is a clone of source. The returned variable it must be freed with both, v free() and free() functions. void v set(var t *dest, const var t *src) Copies the src to dest. Example void { myfunc() var_t myvar;
E.1.4 Strings
void v tostr(var t *arg) Converts variable arg to string. char* v getstr(var t *var) Returns the string-pointer of variable var. If the var is not a string, it must be converted to string with the v tostr() function. void v zerostr(var t *var) Resets the variable var to a zero-length string. void v setstr(var t *var, const char *string) Sets the string value string to the variable var.
74
void v strcat(var t *var, const char *string) Adds the string string to string-variable var. void v setstrf(var t *var, const char *fmt, ...) Sets a string value to variable var using printf() style. The buer size is limited to 1KB for OS LIMITED (PalmOS), otherwise 64kB.
E.1.5 Arrays
SB arrays are always one-dimension. The multiple dimensions positions are calculated at run-time. Each element of the arrays is a var_t object. var t* v elem(var t *array, int index) Returns the variable pointer of the element index of the array. index is a zero-based, one dimention, index. int v asize(var t *array) Returns the number of the elements of the array. void v resize array(var t *array, int size) Resizes the 1-dimention array. void v tomatrix(var t *var, int r, int c) Converts the variable var to an array of r rows and c columns. void v toarray1(var t *var, int n) Converts the variable var to an array of n elements. void v setintarray(var t *var, int32 *itable, int count) Makes variable var an integer array of count elements. The values are specied in itable. void v setrealarray(var t *var, double *rtable, int count) Makes variable var a real-number array of count elements. The values are specied in rtable. void v setstrarray(var t *var, char **ctable, int count) Makes variable var a string array of count elements. The values (which are copied) are specied in ctable. Example void { myfunc() int var_t c_array[] = { 10, 20, 30 }; myvar;
75
76
int i; for ( i = 0; i < param_count; i ++ ) { param = params[i].var_p; print_variable(0, param); } } /* typical function */ int m_funcA(int param_count, slib_par_t *params, var_t *retval) { v_setstr(retval, "funcA() works!"); return 1; /* success */ } /* the node-type of function/procedure tables */ typedef struct { char *name; /* the name of the function */ int (*command)(slib_par_t *, int, var_t *); } mod_kw; /* functions table */ static mod_kw func_names[] = { { "FUNCA", m_funcA }, // function A { NULL, NULL } }; /* commands table */ static mod_kw proc_names[] = { { "CMDA", m_cmdA }, // command A { NULL, NULL } }; /* returns the number of the procedures */ int sblib_proc_count(void) { int i; for ( i = 0; proc_names[i].name; i ++ ); return i; } /* returns the number of the functions */ int sblib_func_count(void) {
77
int i; for ( i = 0; func_names[i].name; i ++ ); return i; } /* returns the index procedure name */ int sblib_proc_getname(int index, char *proc_name) { strcpy(proc_name, proc_names[index].name); return 1; } /* returns the index function name */ int sblib_func_getname(int index, char *proc_name) { strcpy(proc_name, func_names[index].name); return 1; } /* execute the index procedure */ int sblib_proc_exec(int index, int param_count, slib_par_t *params, var_t *retval) { return proc_names[index].command(params, param_count, retval); } /* execute the index function */ int sblib_func_exec(int index, int param_count, slib_par_t *params, var_t *retval) { return func_names[index].command(params, param_count, retval); }
Makele
78
MODNAME=mymod MODLIBS=-lmysqlclient MODIDIR=/usr/lib/sbasic/modules CINC=-I/opt/sbasic/source CFLAGS=-Wall -fPIC $(CINC) -D_UnixOS -DLNX_EXTLIB all: $(MODIDIR)/$(MODNAME).so $(MODIDIR)/$(MODNAME).so: $(MODNAME).c -mkdir -p $(MODIDIR) gcc $(CFLAGS) -c $(MODNAME).c -o $(MODNAME).o gcc -shared -Wl,-soname,$(MODNAME).so -o $(MODNAME).so $(MODNAME).o $(MODLIBS) mv $(MODNAME).so $(MODIDIR) ldconfig -n $(MODIDIR) clean: -rm -f *.so *.o $(MODIDIR)/$(MODNAME).so
Appendix F: Glossary
79
Appendix F Glossary
What it could be good to know. ANSI The American National Standards Institute. This organization produces many standards, among them the standards for the C and C++ programming languages. See also "ISO". An program consists of a series of commands, statements, and expressions. The program executed by an interpreted language command by command until it ends. Another name for an program. ... Short for "Binary Digit". All values in computer memory ultimately reduce to binary digits: values that are either zero or one. Computers are often dened by how many bits they use to represent integer values. Typical systems are 32-bit systems, but 64-bit systems are becoming increasingly popular, and 16-bit systems are waning in popularity.
Program
Script Bit
Character Set The set of numeric codes used by a computer system to represent the characters (letters, numbers, punctuation, etc.) of a particular country or place. The most common character set in use today is ASCII (American Standard Code for Information Interchange). Many European countries use an extension of ASCII known as ISO-8859-1 (ISO Latin-1). Compiler A program that translates human-readable source code into machine-executable object code. The object code is then executed directly by the computer or by a virtual-machine. See also "Interpreter". The situation in which two communicating processes are each waiting for the other to perform an action.
Deadlock
Environment Variables A collection of strings, of the form name=val, that each program has available to it. Users generally place values into the environment in order to provide information to various programs. Typical examples are the environment variables HOME and PATH. Escape Sequences A special sequence of characters used for describing nonprinting characters, such as \n for newline or \033 for the ASCII ESC (Escape) character. Flag A variable whose truth value indicates the existence or nonexistence of some condition.
Free Software Foundation FSF A nonprot organization dedicated to the production and distribution of freely distributable software. It was founded by Richard M. Stallman. GNU General Public License GNU GPL This document describes the terms under which binary library archives or shared objects, and their source code may be distributed.
Appendix F: Glossary
80
With few words, GPL allows source code and binary forms to be used copied and modied freely. GMT GNU "Greenwich Mean Time". It is the time of day used as the epoch for Unix and POSIX systems. "GNUs not Unix". An on-going project of the Free Software Foundation to create a complete, freely distributable, POSIX-compliant computing environment.
GNU/Linux A variant of the GNU system using the Linux kernel, instead of the Free Software Foundations Hurd kernel. Linux is a stable, ecient, full-featured clone of Unix that has been ported to a variety of architectures. It is most popular on PC-class systems, but runs well on a variety of other systems too. The Linux kernel source code is available under the terms of the GNU General Public License, which is perhaps its most important aspect. Hexadecimal Base 16 notation, where the digits are 09 and AF, with A representing 10, B representing 11, and so on, up to F for 15. Hexadecimal numbers are written in SB using a leading 0x or &H, to indicate their base. Thus, 0x12 is 18 (1 times 16 plus 2). I/O Interpreter A program that reads and executes human-readable source code directly. It uses the instructions in it to process data and produce results. ISO The International Standards Organization. This organization produces international standards for many things, including programming languages, such as C and C++. Abbreviation for "Input/Output", the act of moving data into and/or out of a running program.
Lesser General Public License LGPL This document describes the terms under which binary library archives or shared objects, and their source code may be distributed. Octal Base-eight notation, where the digits are 07. Octal numbers are written in SB using a leading &o, to indicate their base. Thus, &o13 is 11 (one times 8 plus 3). The name for a series of standards that specify a Portable Operating System interface. The "IX" denotes the Unix heritage of these standards. Variables and/or functions that are meant for use exclusively by this level of functions and not for the main program. See LOCAL, "Nested Functions".
POSIX Private
Recursion When a function calls itself, either directly or indirectly. Redirection Redirection means performing input from something other than the standard input stream, or performing output to something other than the standard output stream.
Appendix F: Glossary
81
In Unices, you can redirect the output of the print statements to a le or a system command, using the >, >>, |, and |& operators. You can redirect input to the INPUT statement using the <, |, and |& operators. RegExp Regulat Expression Short for regular expression. A regexp is a pattern that denotes a set of strings, possibly an innite set. For example, the regexp R.*xp matches any string starting with the letter R and ending with the letters xp. Search Path In SB, a list of directories to search for SB program les. In the shell, a list of directories to search for executable programs. Seed Shell The initial value, or starting point, for a sequence of random numbers. The command interpreter for Unix, POSIX-compliant systems, DOS and WinNT/2K/XP (CMD). The shell works both interactively, and as a programming language for batch les, or shell scripts. A computer operating system originally developed in the early 1970s at AT&T Bell Laboratories. It initially became popular in universities around the world and later moved into commercial environments as a software development system and network server system. There are many commercial versions of Unix, as well as several work-alike systems whose source code is freely available (such as GNU/Linux, NetBSD, FreeBSD, and OpenBSD).
Unix
82
83
The Cover Texts are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Transparent copy of the Document means a machine-readable copy, represented in a format whose specication is available to the general public, 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, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent le format whose markup has been designed to thwart or discourage subsequent modication by readers is not Transparent. A copy that is not Transparent is called Opaque. Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modication. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only. The Title Page means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, Title Page means the text near the most prominent appearance of the works title, preceding the beginning of the body of the text. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, 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. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies of the Document numbering more than 100, and the Documents license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long
84
as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to t legibly, you should put the rst ones listed (as many as t reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, 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. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modied Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modied Version under precisely this License, with the Modied Version lling the role of the Document, thus licensing distribution and modication of the Modied Version to whoever possesses a copy of it. In addition, you must do these things in the Modied Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modications in the Modied Version, together with at least ve of the principal authors of the Document (all of its principal authors, if it has less than ve). C. State on the Title page the name of the publisher of the Modied Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modications adjacent to the other copyright notices. F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modied Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Documents license notice. H. Include an unaltered copy of this License.
85
I. Preserve the section entitled History, and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modied Version as given on the Title Page. If there is no section entitled History in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modied Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. 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, or if the original publisher of the version it refers to gives permission. K. In any section entitled Acknowledgements or Dedications, preserve the sections title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section entitled Endorsements. Such a section may not be included in the Modied Version. N. Do not retitle any existing section as Endorsements or to conict in title with any Invariant Section. If the Modied Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modied Versions license notice. These titles must be distinct from any other section titles. You may add a section entitled Endorsements, provided it contains nothing but endorsements of your Modied Version by various partiesfor example, statements of peer review or that the text has been approved by an organization as the authoritative denition of a standard. You may add a passage of up to ve words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modied Version. 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. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added 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 Modied Version. 5. COMBINING DOCUMENTS
86
You may combine the Document with other documents released under this License, under the terms dened in section 4 above for modied versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodied, and list them all as Invariant Sections of your combined work in its license notice. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but dierent contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections entitled History in the various original documents, forming one section entitled History; likewise combine any sections entitled Acknowledgements, and any sections entitled Dedications. You must delete all sections entitled Endorsements. 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modied Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an aggregate, and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Documents Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate. 8. TRANSLATION Translation is considered a kind of modication, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may
87
include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may dier in detail to address new problems or concerns. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document species that a particular numbered version of this License or any later version applies to it, you have the option of following the terms and conditions either of that specied version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.
If you have no Invariant Sections, write with no Invariant Sections instead of saying which ones are invariant. If you have no Front-Cover Texts, write no Front-Cover Texts instead of Front-Cover Texts being list; likewise for Back-Cover Texts. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
88
A
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ABSMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ABSMIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACOSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACOTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACSC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ACSCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . APPEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ARC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASECH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ASINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ATAN2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ATANH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ATN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 50 50 46 51 51 52 52 52 52 32 39 58 52 52 51 52 65 51 51 52 51
D
DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DATEDMY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DATEFMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DELAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DERIV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DETERM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIFFEQN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIRB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DIRWALK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DISCLOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DRAW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DRAWPOLY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 34 34 34 50 34 32 54 53 54 24 67 67 67 67 48 59 39 39
B
BALLOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCOPY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BEEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BGETC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BLOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BPUTC# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BSAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BYE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 37 58 41 47 58 37 47 37 66
E
EMPTY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENCLOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ENV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35, ENVIRON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35, EOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ERA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ERASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EXEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EXIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EXIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31, EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 59 29 36 36 47 67 30 35 46 66 52
C
CAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CBS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CDBL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CEIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CHAIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CHART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CHDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 58 67 43 51 35 39 48
89
EXPRSEQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
F
FILES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FORMAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FRAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FREEFILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 51 51 26 61 51 33 45
G
GOSUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 GOTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
H
HELP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 HEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
LEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINE INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINE INPUT# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINEINPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINEINPUT# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINEQN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LINPUT# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOCATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOG10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOGPRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31 24 40 65 47 65 47 53 65 47 66 67 65 48 52 52 36 58 58
M I
IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28, INKEY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47, INPUT# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INTERSECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INVERSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ISARRAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ISDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ISFILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ISLINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ISNUMBER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ISSTRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 65 65 47 32 60 51 55 53 31 47 47 47 31 31 M3APPLY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M3IDENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M3ROTATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M3SCALE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M3TRANS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MALLOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MERGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MKDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.CONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.DBS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.DISCONNECT . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.FIELDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.QUERY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.TABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MYSQL.USE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 55 56 56 56 36 50 67 60 50 48 68 68 68 68 68 68 68
J
JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 JULIAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
K
KILL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
N
NEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 NOSOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 NUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
L
LABEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LBOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LCASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LEFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LEFTOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LEFTOFLAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 43 58 59 60 60
O
OCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . OPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 58 25 45 12
90
P
PAINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PAUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PEEK[{16|32}] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PLAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PLOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POKE[{16|32}] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POLYAREA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POLYEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PRINT# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PTDISTLN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PTDISTSEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PTSIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 44 36 43 41 39 40 37 55 55 50 64 47 40 55 55 55
Q
QUIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
R
RAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RANDOMIZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . READ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . READ# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . REM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RENAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RENUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . REPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RETURN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RGB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RGBF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RIGHTOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RIGHTOFLAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RINSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RMDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ROUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RTE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RUN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36, 50 43 30 48 40 24 48 67 27 60 29 25 41 41 59 60 60 60 48 43 53 51 33 58 66
SEEK# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEGCOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEGLEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEGSIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SINPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SPLIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SPRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SQR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SQUEEZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STATMEAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STATMEANDEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STATSPREADP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STATSPREADS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STKDUMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . STRING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SUMSQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SWAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
47 55 55 55 50 50 51 51 61 34 42 58 58 62 61 50 59 53 53 53 53 37 29 58 61 52 53 44
T
TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TANH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TEXTHEIGHT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TEXTWIDTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TICKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TICKSPERSEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TIMEHMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TIMER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TLOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TRANSLATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TROFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TRON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TSAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TXTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TXTW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TYPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 51 40 40 33 33 33 33 33 46 61 59 36 36 46 40 40 67
S
SAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEARCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SECH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SEEK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 35 52 52 48
U
UBOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UCASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UPPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . USRCALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 58 58 37
91
V
VADR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 VAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 VIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
WINDOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 WRITE# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
X
XPOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
W
WEEKDAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 WHILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Y
YPOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
92
Appendix I
B
Variable Index
P
PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
BPP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
C
COMMAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 CWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
S
SBVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
T
TRUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
F
FALSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
V
VIDADR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
H
HOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
X
XMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
O
OSNAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 OSVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Y
YMAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10