SmallBASIC version 0.7.0a

Generic

Usefull notes for beginners:
____________________________

How to read the syntax:

Everything is written inside
of [] characters are
optional values.
Everything is written inside
of {} characters means you
must select one of them.
The symbol | means OR.
The symbols ... means you
can repeat the previous
syntax.
The keywords are written
with capital letters.

Examples:
Syntax: TEST {1|2}

Valid calls:
TEST 1
TEST 2

Syntax: TEST [HI]

Valid calls:
TEST
TEST HI

____________________________

Limits:
____________________________

Max. length of 
   code text line: 511 chars
Max. keyword length: 32 char
Max. num. of parameters: 64
Max. arrays dimentions: 4
Numeric value range: 64b FPN
Max. string size: 32KB
Max. number of file handles:
  PalmOS: 16
  Other: 256
INPUT (console only)
  limit: 255B per call.
  up to 16 variables.
Max. number of colors: 16
Max. bytecode size: 64KB
  (by using CHAIN you can
  run progs > 64KB)
Background sound queue
  size: 256 notes

System events are checked
every 50ms

PalmOS:
  Be careful with memory
  there is no too much.
____________________________

Variables:
____________________________

There is no data types. All
user variables (include
arrays) are 'VARIANT'.

SB uses internaly 3 types
1. Integer (32bit)
2. Real    (64bit)
3. String  (<32KB)

Variable names can use any
alphanumeric characters,
and the '$'. The first char
of the name cannot be
a digit.
The symbol '$' is supported
for compatibility. Its use
is meanless.

Example:

a="123"
a$=1
? a<>a$
REM displays 1 (true)
____________________________

System Variables:
____________________________

OSVER  - OS Version
OSNAME - OS Name
SBVER  - SmallBASIC Version
PI     - 3.14..
XMAX,YMAX
       graphics display max.
BPP    - Bits per pixel
CWD    - Current Working
         Directory
HOME   - User's directory
____________________________

Operators (by priority):
____________________________

( )       = parenthesis
-         = unary
^         = power

* / \     = mul, div, idiv
% MOD     = modulus

+ -       = add, sub

=> =<  = 
>= <= <>  = compare

AND & OR  |
NOT ! XOR ~
BAND BOR
          = logical & bitwise

:         = EOL

[,;]       = code array
____________________________

Base convertion:
____________________________

&H|0x hex. ex: 0x1F + &H1F
&o|0o oct. ex: 0o33 = &o33
&b|0b bin. ex: 0b11 = &b11
____________________________

Meta-commands:
____________________________

#!...
  Used by Unix to make
  SB source runs as script
  executable

#sec:section name
  Used internaly to store
  the section name

  DON'T USE IT

#inc:"file"
#inc:file
  Used to include a SB
  source file into current
  BASIC code

Example:
...
#inc:"mylib.bas"
...
MyLibProc "Hi"
____________________________

Matrices
____________________________

Define a 3x2 matrix

A=[11,12; 21,22; 31,32]

That creates the array

    | 11  12 |
A = | 21  22 |
    | 31  32 |

The comma used to separate
column items; the semi-colon
used to separate rows.

Values between columns can
be omitted.

Example:

A=[;;1,2;3,4,5]

This creates the array

    | 0  0  0 |
A = | 1  2  0 |
    | 3  4  5 |

Operators:

Add/sub:

B = [1, 2; 3, 4]
C = [5, 6; 7, 8]

A = B + C
C = A - B

EQ:
bool=(A=B)

Unary:

A2 = -A

Multiply:

A = [1, 2; 3, 4]
B = [5 ; 6]

C = A * B

D = 0.8 * A

Inverse:
A = [1,-1,1;2,-1,2;3,2,-1]
? INVERSE(A)

Gauss-Jordan:

? "Solve this:"
? "  5x - 2y + 3z = -2"
? " -2x + 7y + 5z =  7"
? "  3x + 5y + 6z =  9"
?
A = [5,-2,3; -2,7,5; 3,5,6]
B = [-2;7;9]
C = LinEqGJ(A, B)
? "[x;y;z] ="; C

Note:
There is a problem with 1
dimension arrays.

Because 1-dim arrays does
not specify how SB must
see them.

Example:
DIM A(3)

A = | 1 2 3 |

or
    | 1 |
A = | 2 |
    | 3 |

And because this is not the
same thing. (ex. for
multiplication)

So the default is columns
ex:
DIM A(3) ' or A(1,3)

A = | 1 2 3 |

For vertical arrays you
must declare it as 2-dim
arrays Nx1

DIM A(3,1)

    | 1 |
A = | 2 |
    | 3 |

Nested arrays are allowed

A=[[1,2],[3,4]]

A = | |1 2| |3 4| |
____________________________

Subroutines/Functions:
____________________________

SUB name
  [([BYREF] par1 [,
  ...[BYREF] parN)]]

  [LOCAL var[, var[, ...]]]
  [EXIT SUB]

END

FUNC name
  [([BYREF] par1 [,
  ...[BYREF] parN)]]

  [LOCAL var[, var[, ...]]]
  [EXIT FUNC]

  name=return-value
END

Use function's name
to return the value.

Nested procedures/functions
are allowed (like Pascal).

Example:

FUNC f(x)
  FUNC f11
    FUNC f21
        f21=21
        END
  END
  FUNC f12
  f12=12
  END

? f11
? f21: REM ERROR
f=x+f11+f
END

____________________________

The parameters are 
'by value' by default.
Passing parameters by value
means the executor makes
a copy of the parameter to
stack. The value in caller's
code will not be changed.

Use BYREF keyword for
passing parameters 
'by reference'. 
Passing parameters by
reference means the
executor push the pointer
of variable into the stack.
The value in caller's code
will be the changed.

Example:

' 'by value'
SUB F(x)
x=1
END

x=2
F x
? x:REM displays 2

' 'by reference'
SUB F(BYREF x)
x=1
END

x=2
F x
? x:REM displays 1
____________________________

Use the LOCAL keyword for
local variables.

LOCAL creates variables
(dynamic) at routine's
code.

Example:

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 with ().

When using arrays as
parameters its better to use
them as BYREF; otherwise 
their data will be
duplicated.

Example:
SUB FBR(BYREF tbl())
? FRE(0)
...
END

SUB FBV(tbl())
? FRE(0)
...
END

' MAIN
DIM dt(128)
...
? FRE(0)
FBR dt()
? FRE(0)
FBV dt()
? FRE(0)

Avoid to use nested
arrays as BYREF parameters.
SB code is not prepared for
that. Sorry.
____________________________

On a multi-section 
applications sub/funcs needs
declaration on the main
section.

Example:
#sec:Main
declare func f(x)

#sec:another section
func f(x)
...
end
____________________________

Passing & returing arrays,
using local arrays.

Example:

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(4)
v()=fill(v())

____________________________

Statements:
____________________________

'|#|REM ...

Remarks.
The # can be used as remarks
only in the first pos. of
the text line.
____________________________

[LET] var = expr

Assign 'expr' to variable
'var'.

Example:
z=1
z="Change to string"

DIM v(4)
v2()=v()
z=v():REM make z copy of v()
____________________________

CONST var = expr

Assign 'expr' to variable
'var' and make it READ-ONLY.
____________________________

DIM var( [lower TO] 
             upper [, ...])

Creates an array.
____________________________

[LABEL] label

Defines a label. There are
two kinds of labels. Numeric
and alphanumeric.

Numeric labels does not 
needed the keyword LABEL,
but alphanumeric does.

Example:
1000 ? "Hello"

LABEL AlphaLabel
? "Hello"
...

GOTO 1000
GOTO AlphaLabel
____________________________

GOTO label

Branches to a specified
label.
____________________________

GOSUB label - RETURN

Branches to an old-style
subroutine. The subroutine
returns to GOSUB's next
instruction with RETURN.
____________________________

ON expr GOTO label-list
ON expr GOSUB label-list

Branches to one of the 
several locations, depending
of the value of the 'expr'.
____________________________

FOR var = expr TO expr
         [STEP expr] - NEXT

Repeats a code block for
a specified number of times.
____________________________

WHILE expr - WEND

WHILE/WEND code block, loops
while 'expr' is true.
____________________________

REPEAT - UNTIL expr

REPEAT/UNTIL code block, 
loops while 'expr' is false.
____________________________

IF expr  [THEN] -
         [ELSE|ELIF|ELSEIF]
         - ENDIF|FI

Executes a code block
depending on specified
conditions.
____________________________

IF expr THEN
          [num-label]|[...]
   [ELSE [num-label]|[...]]

Old-style inline-IFs.
____________________________

STOP|END

Stops the program execution.
____________________________

RESTORE label
READ var[, var ...]
DATA n[,n ...]

DATA specifies values to
be read by READ.

RESTORE specifies the
position of the next
data to be read.

READ reads values from
current data position.

Example:

RESTORE MyDataBlock
FOR I=1 TO 3
        READ v
        PRINT v
NEXT
END

LABEL MyDataBlock
DATA 1,2,3
____________________________

ERASE var1[, var2[,
  ... varN]]

Frees the memory used by the
specified arrays or 
variables. 
After that these variables
turned to simple integer
with value 0

Example:
DIM x(100)
...
? fre(0)
ERASE x
? fre(0)
? x(1):REM ERROR
____________________________

EXIT [FOR|LOOP|SUB|FUNC]

By itself exits from last
command block (loop, 
for-loop or routine)

FOR - Exit from the last
  FOR-NEXT loop

LOOP - Exit from the last
  WHILE/REPEAT loop

SUB - Return from the
  current routine

FUNC - Return from the
  current function
____________________________

LEN(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 integer
  returns 1
if x is a real
  returns 1

____________________________

EMPTY(x)

if x is a string
  returns true if the 
  len(x) is 0;
if x is an integer or real
  returns true if the x = 0
if x is an array
  returns true if all the
  elements of array are
  empty


System
____________________________

FRE(0|-1|-2|-3)

Returns information about
system memory

 0 - free memory
-1 - largest block of
  integers
-2 - free stack
-3 - largest free block

Unix only:
-10 - total RAM
-11 - used
-12 - free
-13 - shared
-14 - buffers
-15 - cached
____________________________

TICKS() - the system-ticks
  count

TICKSPERSEC() - the number
  of ticks per second
____________________________

TIMER - returns the number
  of seconds from midnight

TIME$ - returns the current
  time as string "HH:MM:SS"

DATE$ - returns the current
  day as string "DD/MM/YYYY"
____________________________

DELAY ms

Delay for a specified amount
of milliseconds
____________________________

CHAIN file

Transfers the control to
another SB program

Example:
CHAIN "PROG2.BAS"
____________________________

ENVIRON "var=args"
ENVIRON$("var")

Set/return environment 
variable

Note:
Non-PalmOS only
____________________________

RUN file
RUN("command")

Runs an executable.
The RUN() returns a string
with the output of the
command.

PalmOS:
  the 'file' is the creator 
  ID. The RUN() does not
  supported.

____________________________

Debug:
____________________________

TRON/TROFF

TRACE ON/OFF. When trace
mechanism is ON, the SB
displays each line number
as the program is executed
____________________________

LOGPRINT ...

PRINT to SB's logfile
____________________________

BCDUMP [len]

Displays the 'len' next
bytes of byte-code
____________________________

STKDUMP

Displays the SB's internal
executor's stack



Graphics & Sound
____________________________

Colors:
Mono: 0=black, 15=white,
      any=gray
2bit: 0=black, 15=white
      1-6,8=dark-gray,
      7,9-14=light-gray
4bit: 16 colors of gray
8bit: 16 Standard VGA colors

STEP keyword:
The STEP keyword calculates
the next x,y parameters 
relative to current position
____________________________

ARC [STEP] x,y,r,
       astart,aend[,aspect]
       [COLOR color]

Draws an arc

astart,aend = first,last
angle in rads.
____________________________

CHART {LINECHART|BARCHART}
     , array() [, {0|1|2|3}
     [, x1, y1, x2, y2]]

Draws a chart of array
values in the rectangular
area x1,y1,x2,y2

type:
0 = simple
1 = with marks
2 = with ruler
3 = with marks & ruler
____________________________

CIRCLE [STEP] x,y,r
           [,aspect]
           [COLOR color]
           [FILLED]

Draws a circle/ellipse.
____________________________

COLOR fg [, text_bg]

Changes the current pen
color
____________________________

DRAWPOLY array() [,x-origin
     ,y-origin [, scalef]]
     [COLOR color] 
     [FILLED]

Draws a polyline

even elements for x
       (starting from 0)
odd elements for y
____________________________

DRAW string
____________________________

LINE [STEP] x,y
           [{,|STEP} x2,y2]
                   [COLOR color]

Draws a line
____________________________

PSET [STEP] x,y
              [COLOR color]

Draw a pixel at x,y position
____________________________

RECT [STEP] x,y
           [{,|STEP} x2,y2]
           [COLOR color]
                   [FILLED]

Draws a rectangular 
parallelogram
____________________________

TXTW(s), TXTH(s)

Returns the text 
width/height of string s
in pixels
____________________________

POINT(x[,y])

Returns the value of the
pixel at x,y

if y does not specified
x contains the info-code
0 = returns the current X
  graphics position (since
  its used for STEP keyword)
1 = returns the current Y
  graphics position
____________________________

PAINT [STEP] x, y 
[,fillcolor [,bordercolor]]

____________________________

VIEW [x1,y1,x2,y2]
____________________________

WINDOW [x1,y1,x2,y2]
____________________________

BEEP

Generates a beep sound
____________________________

PLAY string

Play musical notes

A-G[-|+|#][nnn][.]
  Play note A..G
  +|# - sharp
  - - flat
  . - multiplier 1.5

On - Octave 0..6
<  - Moves down one octave
>  - Moves up one octave

Nnn - Play note 0..84
  (0 = pause)

Pnnn - Pause 1..64

Lnnn - Length of note 1..64
  (1/nnn)
Tnnn - Tempo 32..255
  Number of 1/4 notes per
  minute.

MS - Staccato (1/2)
MN - Normal (3/4)
ML - Legato

Vnnn - Volume 0..100

MF - Play on foreground
MB - Play on background
____________________________

SOUND freq, dur_ms [, vol]

Plays a sound
Miscellaneous
____________________________

RANDOMIZE [int]

Seeds the random number
generator

____________________________

RND

Returns a random number
from the range 0 to 1
____________________________

LBOUND(array [, dim])
UBOUND(array [, dim])

Returns the lower/upper
bound of the 'array'

The parameter 'dim' is the
array dimension whose bound
is returned

Example:
DIM v1(-4 TO 7)
DIM v2(1 TO 2, 3 TO 4)

? LBOUND(v1):REM -4
? UBOUND(v1):REM 7

? LBOUND(v2):REM 1
? LBOUND(v2,2):REM 3
____________________________

CINT(x) - convert x to
  32b integer

CDBL(x) - convert x to
  64b real number
____________________________

PEN ON|OFF

Enables/Disables the
PEN/MOUSE mechanism.
____________________________

PEN(0..14)

Returns the PEN/MOUSE data.

Values:
0 - true (non zero) if there
  is a new pen or mouse
  event
1 - PEN: last pen-down x;
  MOUSE: last mouse button
  down x 
2 - Same as 1 for y
3 - true if the PEN is down;
  mouse left-button is
  pressed
4 - PEN: last/current x, 
  MOUSE: the current x
  position only if the left
  mouse button is pressed
  (like PEN is down)
5 - Same as PEN(4) for y

Mouse buttons (non PalmOS):

10 - current mouse x pos.
11 - current mouse y pos.
12 - true if the left mouse
  button is pressed
13 - true if the right mouse
  button is pressed
14 - true if the middle
  mouse button is pressed

____________________________

PAUSE [secs]

Pauses the execution for a
specified length of time, or
until user hit the keyboard.

File system
____________________________

Special file names:

"COM1:[speed]" -
  Serial port 1

"COM2:[speed]" - 
  Serial port 2
  PalmOS has no COM2

"PDOC:filename"
  Compressed PDOC files for
  PalmOS or PDB/PDOC files
  files on other systems.
  PDOCFS opens and
  uncompress the file on
  OPEN; and compress the
  file 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 file on other
  systems.
  Memo records (virtual
  files) are limited to 3935
  bytes

"SOCL:server:port"
  Socket client.
  Its not tested on PalmOS
  Its not exists for DOS

Example:

OPEN "COM1:" AS #1

OPEN "COM2:38400" AS #2

____________________________

FREEFILE

Returns an unused file
handle
____________________________

OPEN "file" [FOR {INPUT|
             OUTPUT|APPEND}]
             AS #fileN

Opens a file or device
____________________________

CLOSE #fileN

Close a file handle
____________________________

EXIST(fileName)

Returns true if the fileName
exists
____________________________

EOF(fileN)

Returns true if the file
pointer is at end of the
file.

For COMx and SOCL VFS its
returns true if the
connection it is broken.
____________________________

PRINT #fileN{,|;} var1
                     [,varN]

Write string to a file
____________________________

LINEINPUT #fileN{,|;} var$

Reads a whole text line from
file
____________________________

INPUT$(len[,fileN])

Reads 'len' bytes from file
or console (if fileN is 
omitted).
____________________________

INPUT #fileN{,|;} var1 [,
  var2 [, ...]]

Reads data from file
____________________________

SEEK #fileN{,|;} pos

Sets file position for
the next read/write
____________________________

SEEK(fileN)

Returns the current file
position
____________________________

LOF(fileN)

Returns the length of file
in bytes

For devices; returns the
number of available data
____________________________

KILL "file"

Deletes the specified file
____________________________

WRITE #fileN; var1 [, ...]
READ #fileN; var1 [, ...]

The READ/WRITE command set
is used to store variables
to a file as binary data.

The common problem with
INPUT/PRINT set is there
are many conficts with
datas. 

Example:
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 finds 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.

Notes:
The parameters can be
variables ONLY.

Its very bad idea to mixed
READ/WRITE commands with
INPUT/PRINT commands in
the same file.
____________________________

COPY "file", "newfile"

Makes a copy of specified 
file to the 'newfile'
____________________________

RENAME "file", "newfile"

Renames the specified file
____________________________

MKDIR dir$
CHDIR dir$
RMDIR dir$

Notes:
Non-PalmOS only.
____________________________

FILES(wildcards)

Returns an array with the
filenames.

If there is no files
returns an empty array
(1 element, with value "")

PalmOS:
For PalmOS returns only
the user-files.

Example:

? FILES("*")

Note: 
To use file on MEMO or 
PDOC or any other virtual
file system you must use
FILES("VFSx:*")

Example:
? FILES("MEMO:*")

Mathematics:
____________________________

All angles are in radians.

ABS(x) - Absolute value of x
COS(x) - Cosine of x
SIN(x) - Sine of x
TAN(x) - Tangent of x
ACOS(x) - Arc cosine of x
ASIN(x) - Arc sine of x
ATAN(x) - Arc tangent of x
ATAN2(x,y) - Arc tangent
  of two variables

Hyperbolic functions:

COSH(x), SINH(x), TANH(x)
ACOSH(x), ASINH(x), ATANH(x)

EXP(x) - the value of e
  raised to the power of x
LOG(x) - natural logarithm
  of x
LOG10(x) - the base-10
  logarithm of x

POW(x,y) - x raised to
  power of y
SQR(x) - square root of x

INT(x) - rounds x downwards
  to the nearest integer
FIX(x) - rounds x upwards
  to the nearest integer
ROUND(x [,decs])
  rounds the x to the
  nearest integer or
  fp with 'decs' decimal
  digits.

SGN(x) - sign of x
  +1 for positive,
  -1 for negative and
   0 for zero

DEG(x) - radians to degrees
RAD(x) - degrees to radians

____________________________

MAX(...), MIN(...)
ABSMIN(...), ABSMAX(...)

Maximum/Minimum value of
parameters. Parameters can
be anything (arrays, ints,
reals, strings).

ABSMIN/ABSMAX returns the
absolute min/max value.

Example:
? MAX(3,4,8)
? MIN(array(),2,3)
? MAX("abc","def")
____________________________

SUM(...)
    Sum of value

SUMSQ(...)
    Sum of square value 

STATMEAN(...)
    Arithmetical mean

STATMEANDEV(...)
    Mean deviation

STATSPREADS(...)
    Sample spread

STATSPREADP(...)
    Population spread

Notes:
Sample standard deviation:
    SQR(STATSPREADS(array))

Population standard 
   deviation:
    SQR(STATSPREADP(array))
____________________________

LINEQGJ(A, B [, toler])

Returns an array
with the values of the 
unknowns.
This function solves
equations by using the
Gauss-Jordan method.

A = equations
B = results
toler = tolerance number
  (the absolute value
  lowest acceptable number)
  default = 0 = none

  |x| <= toler : x = 0

Note: The result is a
matrix Nx1. For the SB that
array is two-dimension
array.
____________________________

INVERSE(A)

returns the inverse matrix
of A.

____________________________

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).
____________________________

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)

Area of polyline
____________________________

POLYEXT poly(), BYREF xmin, 
    BYREF ymin, BYREF xmax, 
    BYREF ymax

Returns the polyline's
extents
____________________________

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 = No cross 
    (R = external cross)
1 = One cross
2 = Parallel
3 = Parallel (many crosses)
4 = The cross is one of the
        line segments edges.
____________________________

2D: 3x3 Matrices

M3IDENT	BYREF m3x3

M3ROTATE BYREF m3x3, 
               angle, x, y

M3SCALE BYREF m3x3, 
               x, y, fx, fy

M3TRANS BYREF m3x3, x, y

M3APPLY m3x3, BYREF poly

Example:

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
' scaled by 1.24 
M3APPLY M, poly
DRAWPOLY poly
____________________________

Strings:
____________________________

LEN(s) - length of string
SPC(n)/SPACE$(n) 
  - returns a string
  of 'n' spaces

OCT$(x) - octal value string
  of x
HEX$(x) - hexadecimal value
  string of x
VAL(s) - numeric value of
  string s
STR$(x) - convert x to 
  string
ASC(s) - ASCII code of first
  character of s
CHR$(x) - returns one-char
  string of character with
  ASCII code x
____________________________

LCASE$(s), UCASE$(s)

Converts the string s to 
lower/upper case

Example:
? LCASE$("Hi"):REM hi
? UCASE$("Hi"):REM HI
____________________________

LTRIM$(s), RTRIM$(s)

Removes leading/trailing
spaces from string s

? LEN(LTRIM$("  Hi")):REM 2
____________________________

LEFT$(s,n), RIGHT$(s,n)

Returns the n number of
leftmost/rightmost chars
of string s
____________________________

LEFTOF$(s1,s2),
RIGHTOF$(s1,s2)

Returns the left/right part
of s1 at the position of the
first occurrence of the
string s2 into string s1

Note: s2 does not included
on new string.
____________________________

LEFTOFLAST$(s1,s2),
RIGHTOFLAST$(s1,s2)

Returns the left/right part
of s1 at the position of the
last occurrence of the
string s2 into string s1

Note: s2 does not included
on new string.
____________________________

MID$(s, start [,length])

Returns the part (length)
of the string s starting
from 'start' position

If the 'length' parameter is
omitted, MID$ returns the
whole string from the pos.
'start'.
____________________________

INSTR([start,] s1, s2)

Returns the position of the
first occurrence of the
string s2 into string s1
(starting from the position
'start')

If there is no match, INSTR
returns 0
____________________________

REPLACE$(source, pos, str
    [, len] )

Writes the 'str' into 'pos'
of 'source' and returns the
new string.

This function replaces
only 'len' characters. The
default value of 'len' is
the length of 'str'.

Examples:

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)
____________________________

STRING$(len,{ascii|str})

Returns a string that is 
contains 'len' times of 
string 'str' or the 
character 'ascii'.
____________________________

SPLIT string, delimiters,
  words()

Returns the words of the
specified string into 
array 'words'

Example:

s$="/etc/temp/filename.ext"

SPLIT s$, "/.", v()
FOR i=0 TO UBOUND(v)
  PRINT i;" [";v(i);"]"
NEXT

displays:
0 []
1 [etc]
2 [temp]
3 [filename]
4 [ext]
____________________________

JOIN words(), delimiters,
  string

Returns the words of the
specified string into 
array 'words'

Example:

s$="/etc/temp/filename.ext"

SPLIT s$, "/.", v()
JOIN v(), "/", s$
PRINT "[";s$;"]"

displays:
[/etc/temp/filename/ext]


Console
____________________________

\t		tab (32 pixels)
\a		beep
\r\n	new line (cr/lf)
\xC		clear screen
\e[K	clear to EOL
\e[0m	reset all
        attributes to
                their defaults

\e[1m	set bold on
\e[4m	set underline on
\e[7m	reverse video
\e[21m	set bold off
\e[24m	set underline off
\e[27m	set reverse off
\e[3nm  set foreground
        color. where n:

        0 black
        1 red
        2 green
        3 brown
        4 blue
        5 magenta
        6 cyan
        7 white

\e[4nm  set background
        color.
                (see set foreground)

PalmOS only:

\e[8nm	(n=0..7)
        select system font
\e[9nm	(n=0..3)
        select buildin font

Sony CLIE only:
\e[7nm	(n=0..7)
        select small system font
____________________________

?|PRINT [expr|str [{,|;}
            [expr|str]] ...

Displays a text or the value
of an expression.
____________________________

CAT(x)

Returns console codes

0 - reset
1 - bold on
2 - underline on
3 - reverse on

PalmOS only:
80..87 - select system font
90..93 - select custom font

Example:
? cat(1);"Bold";cat(0)
____________________________

INPUT [prompt {,|;}]
      var[, var [, ...]]

Reads from "keyboard" a text
and store it to variable.
____________________________

INPUT$(len[,fileN])
____________________________

CLS

Clears the screen.
____________________________

AT x,y (in pixels)

Moves the console cursor
to the specified position.

x,y are in pixels
____________________________

LOCATE y,x

Moves the console cursor
to the specified position.

x,y are in character cells.

