




















                    *************************************
                    *                                   *
                    * MBASIC version 1.01               *
                    * Copyright (C) 1992 by Andre Murta *
                    *                                   *
                    *************************************


























I N D E X


**************
* STATEMENTS *
**************


    PRINT...........................7
    FPRINT..........................8
    INPUT...........................9
    FINPUT..........................9
    IF/THEN/ELSE....................10
    GOTO............................10
    FOR/TO/DOWNTO/STEP/NEXT.........11
    GOSUB/RETURN....................11
    WHILE/WEND......................12
    REM.............................12
    LET.............................12
    DIM.............................13
    CLS.............................13
    RANDOMIZE.......................13
    DATA............................13
    READ............................14
    DEFFN...........................15
    LOCATE..........................16
    COLOR...........................16
    TEXTMODE........................17
    FILES...........................17
    INSLINE.........................17
    DELLINE.........................17
    CHAIN...........................17
    HIGHVIDEO.......................18
    NORMVIDEO.......................18
    LOWVIDEO........................18
    CLEAR...........................18
    FLASH...........................18
    WINDOW..........................18
    OPEN............................19
    CLOSE...........................19
    FIELD...........................20
    PUT.............................20
    GET.............................21
    SEEK............................21
    END.............................21

*************
* FUNCTIONS *
*************


    CHR.............................22
    ASC.............................22
    LEN.............................22
    INKEY...........................23
    LEFT............................23
    MID.............................23
    RIGHT...........................24
    SQR.............................24
    LOG.............................24
    EXP.............................25
    POW.............................25
    POW10...........................25
    POW2............................25
    SIN.............................26
    COS.............................26
    TAN.............................26
    ATN.............................26
    ATN2............................26
    ASIN............................27
    ACOS............................27
    SINH............................27
    COSH............................27
    TANH............................27
    PI..............................28
    ABS.............................28
    ASINH...........................28
    ACOSH...........................28
    ATNH............................28
    SGN.............................29
    INT.............................29
    TIMER...........................29
    VAL.............................29
    STR.............................30
    LCASE...........................30
    UCASE...........................30
    TIME............................31
    DATE............................31
    LOG10...........................31
    LOG2............................31
    HYPOT...........................31
    FLOOR...........................32
    CEIL............................32
    RND.............................32
    FMOD............................32
    ETYPE...........................33
    CHDIR...........................33
    RMDIR...........................33
    MKDIR...........................33
    COL.............................34
    ROW.............................34
    COLS............................34
    ROWS............................34
    COPYTEXT........................34
    GETTEXT.........................35
    RENAME..........................36
    KILL............................36
    LOC.............................36
    LOF.............................36
    EOF.............................37
    INSTR...........................37
    SPC.............................37
    TAB.............................37

I N T R O D U C T I O N     T O     M B A S I C

MBASIC  was  developed  as an option to  have a  simple  programming  language
available to  users  who  are  beginners in  computer  science.  MBASIC allows
math  and  string  operations,  also,  a  series of  commands  to  control the
program   flow   and  I/O   operations   are  implemented  in  the interpreter
engine.  The  language  is   similar  and  has  characteristics  of many BASIC
implementations,  it is  very simple to learn and has a editing environment to
allow the user to create, test and deploy BASIC programs very quickly.
The program disk contains two binaries: "based.exe" and "mbasic.exe" and a set
of example programs.  The binary "based.exe" is the editor environment and can
be used to edit and run MBASIC programs. The binary "mbasic.exe" is the actual
interpreter engine and it is necessary in order to run the developed programs,
the   engine  is   automatically   called  by  the  editor  environment,  such
functionality  makes  very  easy  to  develop and test applications inside the
editor environment.


M B A S I C     L I M I T A T I O N S

Maximum variable-name length: 32 chars
Maximum string length: 255 bytes
Numbers: 32 bits / 6 digits precision
Maximum labeled lines: 512 lines
Global variables in memory: 512 vars
Local variables in memory: 128 vars
User functions definitions: 128 funcs
Simultaneous opened files: 64 files
Maximum user functions parameters: 16
Maximum FOR nested: 25
Maximum WHILE nested: 25
Maximum sub routine nested: 25

The  interpreter  needs  at  least 200Kb  of memory to run a program with full
features.  The  amount  of  instructions in  the program code will be relevant
regarding memory use, once the program instructions are stored in memory to be
executed by the interpreter engine.

E N T E R I N G    M B A S I C

There are two  ways to  submit a program to the interpreter, using the command
line,  or  using  the  editor  environment,  right now we  will concentrate in
the command line, due to the fact the  editor will have an entire section only
for it.

After  booting  your system,  This  is the syntax to be observed when entering
MBASIC:

A:> mbasic [-v -q -n -l"logfilename"] -f"programname"

             -v : Activates the verbose mode
             -q : Activates quiet mode
             -n : Shows the interpreter and parser engine versions
             -l"logfilename" : Defines the log file name to be written in disk
                               when option  -v  is used, if this option is not
                               set, the defaul name "log.txt" will be used.
             -f"programname" : Defines the program file to be interpreted

A:> mbasic -q -fhanoi.bas

The  example above will load the program inside the file "hanoi.bas" using the
"quiet" mode.

**********************************
* M B A S I C    C O M M A N D S *
**********************************

*********************
* PRINT [NONEWLINE] *
*********************
The command  PRINT  is  used  to  display information on the video. There is a
similar  command  called  FPRINT  which  can be used to write information to a
system file, but FPRINT will be explained later.
The general syntax for PRINT is:

PRINT list of constants and/or expressions

"list  of constants and/or expressions"  contains  the  data that you  wish to
output to the screen. Numeric constants, numeric expressions, string constants
and string expressions may all be contained within this list. If more than one
value is  to  be output to  the  screen using a  single PRINT statement, these
values must be separated by some type of delimiter.  

When separating output data contained in a PRINT statement, you may use either
a comma or a semicolon.  A semicolon  will cause the next piece of information
to be  written directly  after the preceding data. A comma will cause the next
piece of information to be written at the next available "tab" position in the
screen. Tab positions will be denoted by 8 byte blocks, starting from the last
occurrence of a carriage return.

The  keyword  NONEWLINE  can be used at the end of a PRINT statement, to avoid
the interpreter to put the carriage return at the end of the printed line.


************
* FPRINT # *
************
The command FPRINT is similar to the command PRINT, the exception  is the fact
this  command  will  write the list of constants and/or statements to a opened
file.

The  file  index  must  be  supplied  before the list to be printed, using the
identifier #

Example 1 - Writing numeric data to a sequential file.

Suppose  you  wish to write two numeric values out to a sequential file, using
one FPRINT # command. The file you  wish to write these values out to is named
DATA1.SEQ, and  has  been opened using buffer number 2. The variables you wish
to write out to the file are A, which has been assigned a value of 362, and B,
which has been assigned a value of -2618.7. The following  FPRINT# command may
be used to write these values out to the file:

FPRINT #2, A;B

Example 2 - Writing string data to a sequential file.

Suppose you  wish to write 3 string values out to a sequential file, using one
FPRINT # command.  The  file  you  wish  to write these values out to is named
DATA2.SEQ,  and has  been opened using buffer number 1. The variables you wish
to write  out to the file are A (which has been assigned the value "AMBER"), B
(which  has  been assigned the value "BROWN"), and the string constant "GRAY".
The following FPRINT # command may be used  to write  these values  out to the
file:

FPRINT #1, A;",";B;",";"GRAY"

The  above statement  will cause the  values "AMBER", "BROWN" and "GRAY" to be
written to the file.

See the OPEN command reference,  below in this document, to now more about how
to access files.


*********
* INPUT *
*********
Input  information  from the keyboard. The syntax used with the INPUT# command
is:

INPUT variable

"variable"  is  the variable used to store the numeric value entered. A string
value can be entered using the $ identifier as below:

INPUT $variable

In  this  case,  the  entered  information will be stored in the variable as a
string value.


************
* FINPUT # *
************
The  FINPUT command is used to retrieve information from sequential files. The
syntax used with FINPUT is:

FINPUT #n,$variable

where 'n' is the  buffer  number  used  to  open the file, and variable is the
variable used to store  the information retrieved.
Sequential  files  are  created  by  specifying an OPEN ... WRITING,SEQUENTIAL
command,  followed  by one or more  FPRINT # commands. After a sequential file
has   been  created,  the  information  in  it  may  be accessed  by using the
OPEN ... READING,SEQUENTIAL and FINPUT # commands. The FINPUT # command can be
thought  of  as  performing  a  function  similar  to  the  INPUT command, the
exception being that the information is not entered from the keyboard. Rather,
it is retrieved from the disk.

OPEN "data.seq" FOR READING,SEQUENTIAL AS #1
...
FINPUT #1, $fstr

See the OPEN command reference,  below in this document, to now more about how
to access files.


****************
* IF/THEN/ELSE *
****************
These  commands  are  used to define conditionals in the program code. It will
execute a command depending on specified conditions.  There  are two different
possibilities to the IF/THEN/ELSE statements, for example:

IF a > 10 THEN GOTO 2000

In the  example above,  the program to were the line belongs,  will change its
flow to the label 2000 if the value stored  in the variable 'a' is bigger than
10.

IF a > 10 THEN GOTO 2000 ELSE GOTO 3000

In  the line above,  the  program  flow  will  change to the label 2000 if the
variable  'a'  is bigger than 10 or to the label 3000 if this condition is not
true.


********
* GOTO *
********
The GOTO statement branches to a specified label. For example:

GOTO 1000

will redirect the program flow to the label 1000.


***************************
* FOR/TO/DOWNTO/STEP/NEXT *
***************************
These  commands  are used to repeat a block  of  statements during  a  certain
number of times. For example:

FOR I=1 TO 10
    PRINT "I=";I
NEXT

will  repeat  the  PRINT  statement  10  times.  The  variable 'I' is the loop
variable which holds the repetition counter.

FOR I=10 DOWNTO 1
    PRINT "I=";I
NEXT

Same as above, except that the counter will decrement.

FOR I=0.1 TO 0.9 STEP 0.1
    PRINT "I=";I
NEXT

In  this  example,  the  loop  variable  will  be incremented according to the
expression used after the STEP statement.


****************
* GOSUB/RETURN *
****************
This command branches to and return from a subroutine.

GOSUB 1000
PRINT "Back from subroutine"
...
...
...
1000 PRINT "Starting subroutine"
     calcvar = a+b*(c/10)
     ...
     ...
RETURN

In the example above, the command flow is redirected to the label 1000 through
a  GOSUB call. All the lines inside the subroutine will be executed and when a
RETURN  command  is found, the program flow is redirected to the next sentence
just after the GOSUB call.


**************
* WHILE/WEND *
**************
Execute a series of statements as long as a specified 'condition' is true.

WHILE condition
...
...
...
WEND

The condition could be any logical expression, for example:

a = 10
WHILE a > 0
      PRINT "a=";a
      a=a-1
WEND

All statements  between the block  WHILE/WEND  will  be executed until the 'a'
variable is greater than 0.

*******
* REM *
*******
The statement REM allows explanatory remarks to be inserted in a program.

REM any text
PRINT "The line above is a remark"
PRINT "next command is also a remark" : REM comments

The  line  above is just ignored by the interpreter and does not occupy memory
space when the program is executed.

------------------------
-----IMPORTANT NOTE-----
------------------------
Do not label the lines were you define your comments  or  the interpreter will
allocate memory space also for the REM statements.


*******
* LET *
*******
The LET statement assigns the value of an expression to a variable.

LET variable=expression

The use of the optional  LET keyword  is   optional.  The  variable=expression
assignment statement performs the same action with or without LET.


*******
* DIM *
*******
DIM declares a variable that holds an  array of data.  Different of many BASIC
implementations,  MBASIC  arrays  are  not  typed,  being  able to handle both
numeric and string data.

DIM arr(5)
arr(1) = 10
arr(2) = 20
arr(3) = "String data"
arr(4) = "One more string"
arr(5) = 30.85
REM The line below will produce '10 - String data - 30.85'
PRINT arr(1);" - ";arr(3);" - ";arr(5)


**************
* CLS [LINE] * (HW dependent)
**************
The  CLS  command clean the entire screen.  If the command  is called together
with the  LINE  statement,  it will clean the screen starting from the current
position of the cursor until the end of the current line.

REM The line below cleans the entire screen
CLS
REM The line below cleans the first line of the screen
LOCATE 1,1 : CLS LINE


*************
* RANDOMIZE *
*************
RANDOMIZE initializes the random-number generator. Internally, the interpreter
engine  has  a seed that is used to generate random numbers,  see the function
'rnd()' to know more about random generated numbers.

REM The line below starts the random number seed based in the
REM clock time
RANDOMIZE TIMER


********
* DATA *
********
DATA specifies values to be read by subsequent READ statements.

REM The line below stores 3 constants in the memory space
DATA 10,"text",30.85


********
* READ *
********
READ  reads  those  values  stored  by  DATA statement(s)  and assigns them to
variables.

REM The line below stores 3 constants in the memory space
DATA 10,"text",30.85

REM The line below assigns the stored data to variables
DATA a,b,c

REM The line below prints '10 - text - 30.85' into the screen
PRINT a;" - ";b;" - ";c


*********
* DEFFN *
*********
In  MBASIC,  user  functions  can  be  created  using the DEFFN statement. The
statement in a general form is declared like:

DEFFN name[(parameterlist)] = expression

The  result of  'expression' will  be attributed to the function identified by
'name' and can be also used as a member of an expression.

For example:
DEFFN plus(x,y) = x + y
PRINT 2 * plus(3,5) : REM PRINTS 16

DEFFN  can  handle  any  kind  of MBASIC expressions, including strings. Other
functions (internal and user defined) can be used as part of 'expression'.

DEFFN concat(a,b) = plus(a,b) + "..."

In  the example above, we are assuming the code as a continuation of the first
example, the function accepts two parameters that must be strings to avoid run
time  errors  due to the operation with the constant  "...".  Note that in the
expression  part associated with the function 'concat', the function 'plus' is
called to add two strings which must be the parameters  'a' and  'b'. Below we
have the complete code for the example.

DEFFN plus(x,y) = x + y
DEFFN concat(a,b) = plus(a,b) + "..."
PRINT 2 * plus(3,5) : REM prints 16
PRINT concat("This is", " a test") : REM prints 'This is a test...'

Note  that  is  up  to  the  programmer  to guarantee the parameters passed to
functions are in accordance to the expressions associated to the function.

------------------------
-----IMPORTANT NOTE-----
------------------------
Do  not  label  the  lines  were  you  define  your  functions,  otherwise the
interpreter will not recognize them. It is a good habit to defined all program
functions  at  the beginning or at the end of the program code.


**********
* LOCATE * (HW dependent)
**********
LOCATE moves the cursor to  a specified  position on  the screen.  The general
format for this command is:

LOCATE Y,X

where Y is the screen line and X  is the  screen  column to  where you want to
position the cursor.

*********
* COLOR * (HW dependent)
*********
The COLOR  statement is used do define the background and foreground colors of
the text in the screen. The general form to use COLOR is:

COLOR foreground, background

The 'background' value can be any value between 0 and 7, where:

0 = BLACK
1 = BLUE
2 = GREEN
3 = CYAN
4 = RED
5 = MAGENTA
6 = BROWN
7 = LIGHTGRAY

The 'foreground' value can be any value between 0 and 15, where:

 0 = BLACK
 1 = BLUE
 2 = GREEN
 3 = CYAN
 4 = RED
 5 = MAGENTA
 6 = BROWN
 7 = LIGHTGRAY
 8 = DARKGRAY
 9 = LIGHTBLUE
10 = LIGHTGREEN
11 = LIGHTCYAN
12 = LIGHTRED
13 = LIGHTMAGENTA
14 = YELLOW
15 = WHITE


************
* TEXTMODE * (HW dependent)
************
The general form for the TEXTMODE statement is:

TEXTMODE nlines

This  statement sets the text screen  width to 80 and its  height to the value
given by  the  parameter  nlines.  The parameter could be one of the following
values: 25, 28, 35, 40, 43, 50.  The number of screen lines will depend on the
value passed as parameter to the statement.
On a CGA,  only 25-line screen is supported. On an EGA, you can use 25, 35 and
43. VGA, PGA and MCGA support all of the possible dimensions.


*********
* FILES * (HW dependent)
*********
FILES displays the contents of the current directory or a specified directory.

FILES filespec

Where  filespec  is  a  filename or path (may include a drive and DOS wildcard
characters).

FILES "*.bas"

Shows all the files with extension ".bas" in the current directory.


***********
* INSLINE * (HW dependent)
***********
A blank line is inserted at the current cursor position. The previous line and
lines below it scroll down.


***********
* DELLINE * (HW dependent)
***********
The line the cursor is on is deleted; lines below it scroll up.


*********
* CHAIN *
*********
Transfers  control  from  the current  program to another  MBASIC program. For
example:

CHAIN "c:\bas\sub.bas"

NOTE: it  is assumed the 'sub.bas' program is located under directory 'bas' in
drive C:


*************
* HIGHVIDEO * (HW dependent)
*************
Causes any new characters put on the screen to be bright. 


*************
* NORMVIDEO * (HW dependent)
*************
Resets the text attribute to what it was before the program started.


************
* LOWVIDEO *(HW dependent)
************
Causes any new characters put on the screen to be dim.


*********
* CLEAR *  (HW dependent)
*********
Same effect of CLS, but using the screen attributes. Differently of the
command CLS, CLEAR has no line cleaning capabilities.


*********
* FLASH *  (HW dependent)
*********
Produces a flash effect of the screen, by inverting the screen colors and
reverting it 1 sec later.


**********
* WINDOW *  (HW dependent)
**********
Specifies the window on the screen to be used for future output requests.
The upper left corner of the physical screen is (1,1). 


WINDOW left, top, right, bottom

left: Left upper corner of the new output window.
top: Top line of the new output window.
right: Right most column of the new output window.
bottom: Bottom line of the new output window.


***********************************************************
* OPEN  [READING, WRITING, APPENDING, RANDOM, SEQUENTIAL] *
***********************************************************
Opens a file. The general form is:

OPEN filename FOR mode,method AS #filenumber

filename:  is a string with the name of the file which we need to access,
           the information about drive and directory can be included in
           the string.

mode: is one of the following file access modes: WRITING, READING, APPENDING

method: is one of the following file access methods: RANDOM, SEQUENTIAL

filenumber: is the index used to handle the file access, it can be any value
            between  1  and  64.  MBASIC can handle all the 64 file indexes
            opened at same time.

Example:

OPEN "data.dat" FOR WRITING,RANDOM AS #1

It will open the file "data.dat" for  writing  using  random access,  the file
index to reference the file data is 1.


*********
* CLOSE *
*********
The  CLOSE  statement,  closes  the  file  referenced  by  the index passed as
argument.

Example:

CLOSE #1

Closes the file opened with access index 1.


*********
* FIELD *
*********
Allocates space for variables in a random-access file buffer.
The general format for the field statement is:

FIELD [#]filenumber, fieldwidth AS stringvariable
                    [,fieldwidth AS stringvariable] ...

'filenumber' is the index number of an open file.
'fieldwidth' is the number of characters in the field.
'stringvariable' a variable that identifies the field and contains field data.

Example:
OPEN "data.dat" FOR WRITING,RANDOM AS #1
FIELD #1, 30 AS name, 50 AS address

------------------------
-----IMPORTANT NOTE-----
------------------------
If  you  close  a  file  that  had  field  variables as the  way to access its
contents, the field buffer is lost. If you reopen the file,  you must reassign
the fields using the statement FIELD once more.


*******
* PUT *
*******
PUT writes a random-access buffer to a file.

Example:

OPEN "final.dat" FOR WRITING, RANDOM AS #1
FIELD #1, 30 AS name, 4 as score
name = "John Doe"
score = "99"
PUT #1
CLOSE #1

OPEN "final.dat" FOR READING,RANDOM AS #1
FIELD #1, 30 AS name, 4 as score : REM remember... we are reopening the file
GET #1
PRINT "STUDENT:", name
PRINT "SCORE:", score
CLOSE #1

kill("final.dat")


*******
* GET *
*******
GET reads from a file into a random-access buffer.

Example:

OPEN "final.dat" FOR WRITING, RANDOM AS #1
FIELD #1, 30 AS name, 4 as score
name = "John Doe"
score = "99"
PUT #1
CLOSE #1

OPEN "final.dat" FOR READING,RANDOM AS #1
FIELD #1, 30 AS name, 4 as score : REM remember... we are reopening the file
GET #1
PRINT "STUDENT:", name
PRINT "SCORE:", score
CLOSE #1

kill("final.dat")


********
* SEEK *
********
The SEEK statement sets the file position for the next GET or PUT.

The general form for SEEK is:

SEEK [#]filenumber, position

filenumber: The index number of an open file.
position: The position where the next PUT or GET occurs. For
          random-access files, a record number. For other files,
          the byte position relative to the beginning of the file.
          The first byte is at position 1.


*******
* END *
*******
The END statement ends a program immediately.


*************************************
* M B A S I C     F U N C T I O N S *
*************************************

*******
* CHR *
*******
CHR returns the character corresponding to a specified ASCII code.

CHR(ascii-code)

ascii-code: The ASCII code of the desired character.

Example:
    PRINT ASC("Q") : REM Output is:  81
    PRINT CHR$(65) : REM Output is:  A


*******
* ASC *
*******
ASC returns the ASCII code for the first character in a string expression.

ASC(stringexpression)

stringexpression: Any string expression.

Example:
    PRINT ASC("Q") : REM Output is:  81
    PRINT CHR$(65) : REM Output is:  A


*******
* LEN *
*******
Returns the number of characters in a string.

LEN(stringexpression)

stringexpression: Any string expression.

Example:

a = "Micro Basic"
PRINT LEN(a)


*********
* INKEY *  (HW dependent)
*********
Reads a single character from the keyboard.

INKEY returns a null string if there is no character to return.
For standard keys, INKEY returns a 1-byte string containing the character read.
For extended keys, INKEY returns a 2-byte string made up of the null character (ASCII 0) and the keyboard scan code.

Example:
    PRINT "Press Esc to exit..."
    WHILE INKEY <> CHR(27)
    WEND : REM 27 is the ASCII code for Esc.


********
* LEFT *
********
Return a specified number of leftmost characters in a string.

LEFT(stringexpression,n)

stringexpression: Any string expression.
n:                The number of characters to return, beginning
                  with the leftmost string character.

Example:
    a = "Micro Basic"
    PRINT LEFT(a, 5) : REM Output is:  Micro
    PRINT RIGHT(a, 5) : REM Output is:  Basic


*******
* MID *
*******
The MID function returns part of a string (a substring).

MID(stringexpression, start, length)

stringexpression: The string from which the MID function returns
                  a substring. It can be any string expression.
start:            The position of the first character in the
                  substring being returned.
length:           The number of characters in the substring.


*********
* RIGHT *
*********
Return a specified number of rightmost characters in a string.

LEFT(stringexpression,n)

stringexpression: Any string expression.
n:                The number of characters to return, beginning
                  with the rightmost string character.

Example:
    a = "Micro Basic"
    PRINT LEFT(a, 5) : REM Output is:  Micro
    PRINT RIGHT(a, 5) : REM Output is:  Basic


*******
* SQR *
*******
Returns the square root of a numeric expression.

SQR(numeric-expression)

numeric-expression: A value greater than or equal to zero.

Example:
    PRINT SQR(25), SQR(2) : REM Output is:  5  1.41421

*******
* LOG *
*******
LOG returns the natural logarithm of a numeric expression.

LOG(numeric-expression)

numeric-expression: Any positive numeric expression.

Example:
    PRINT EXP(0), EXP(1) : REM Output is:  1  2.71828
    PRINT LOG(1), LOG(EXP(1)) : REM Output is:  0  1


*******
* EXP *
*******
EXP returns e raised to a specified power, where e is the base of natural
logarithms.

EXP(numeric-expression)

numeric-expression: A number less than or equal to 88.02969.

Example:
    PRINT EXP(0), EXP(1) : REM Output is:  1  2.71828
    PRINT LOG(1), LOG(EXP(1)) : REM Output is:  0  1


*******
* POW *
*******
Returns x raised to the y power.

POW(x,y)

x,y: Any numeric expression.

NOTE: See also the ^ operator.


*********
* POW10 *
*********
returns 10 raised to the expression power.

POW10(expression)

expression: Any numeric expression.


********
* POW2 *
********
Returns 2 raised to the expression power. 

POW2(expression)

expression: Any numeric expression.


*******
* SIN *
*******
Returns the sine of a specified angle passed as an expression.

SIN(angle)

angle: An angle expressed in radians.


*******
* COS *
*******
Returns the cosine of a specified angle passed as an expression.

COS(angle)

angle: An angle expressed in radians.


*******
* TAN *
*******
Returns the tangent of a specified angle passed as an expression.

TAN(angle)

angle: An angle expressed in radians.


*******
* ATN *
*******
ATN returns the arctangent of a specified numeric expression.

ATN(numeric-expression)

numeric-expression: The ratio between the sides of a right triangle.


********
* ATN2 *
********
Returns the arc tangent, in radians, of y/x, with appropriate return values
for positive, negative, or zero values of x. For example atn2(1, 0) returns
PI/2, and atn2(0, -1) returns PI. 

ATN2(y,x)

y,x: Any numeric expression.


********
* ASIN *
********
Returns the arc sine, in radians, of a specified angle passed as an expression.

ASIN(angle)

angle: An angle expressed in radians.


********
* ACOS *
********
Returns the arc cosine, in radians, of a specified angle passed as an expression.

ACOS(angle)

angle: An angle expressed in radians.


********
* SINH *
********
Returns the hyperbolic sine of a specified angle passed as an expression.

SINH(angle)

angle: An angle expressed in radians.


********
* COSH *
********
Returns the hyperbolic cosine of a specified angle passed as an expression.

COSH(angle)

angle: An angle expressed in radians.


********
* TANH *
********
Returns the hyperbolic tangent of a specified angle passed as an expression.

TANH(angle)

angle: An angle expressed in radians.


*********
* ASINH *
*********
ASINH returns the arc hyperbolic sine of an angle.

ASINH(angle)

angle: Any angle expressed in radians


*********
* ACOSH *
*********
ACOSH returns the arc hyperbolic cosine of an angle.

ASINH(angle)

angle: Any angle expressed in radians


********
* ATNH *
********
Returns the arc hyperbolic tangent of an angle.

ATNH(angle)

angle: Any angle expressed in radians.


******
* PI *
******
Returns the value of pi with five decimal digits.

PRINT PI

Prints 3.14159


*******
* ABS *
*******
ABS returns the absolute value of a number.

ABS(numeric-expression)

numeric-expression: Any numeric expression.

Example:
    PRINT ABS(45.5 - 100!)         :  REM Output is:  54.5
    PRINT SGN(1), SGN(-1), SGN(0)  :  REM Output is:  1  -1  0


*******
* SGN *
*******
SGN returns a value indicating the sign of a numeric expression (1 if the
expression is positive, 0 if it is zero, or -1 if it is negative).

SGN(numeric-expression)

numeric-expression: Any numeric expression.

Example:
    PRINT ABS(45.5 - 100!)         :  REM Output is:  54.5
    PRINT SGN(1), SGN(-1), SGN(0)  :  REM Output is:  1  -1  0


*******
* INT *
*******
INT returns the largest integer less than or equal to a numeric expression.

INT(numeric-expression)

numeric-expression: Any numeric expression.

Example:
    PRINT INT(12.54), INT(-99.4) : REM Output is:  12  -99


*********
* TIMER * (HW dependent)
*********
Returns the number of seconds elapsed since midnight.

Use TIMER to time programs or parts of programs, or with the RANDOMIZE
statement to seed the random-number generator.

RANDOM TIMER


*******
* VAL *
*******
VAL converts a string representation of a number to a number.

VAL(stringexpression)

stringexpression: A string representation of a number.

Example:
    PRINT "Decimal 65 is represented in hexadecimal as ";
    PRINT "&H" + STR(41)
    PRINT VAL(RIGHT$("MBasic 1992", 4))


*******
* STR *
*******
STR returns a string representation of a number.

STR(numeric-expression)

numeric-expression: Any numeric expression.

Example:
    PRINT "Decimal 65 is represented in hexadecimal as ";
    PRINT "&H" + STR(41)
    PRINT VAL(RIGHT$("MBasic 1992", 4))


*********
* LCASE *
*********
Convert strings to all lowercase letters.

LCASE(stringexpression)

stringexpression: Any string expression.

Example:
    Test = "THE string"
    PRINT Test
    PRINT LCASE(Test); " in lowercase"
    PRINT UCASE(Test); " IN UPPERCASE"


*********
* UCASE *
*********
Convert strings to all uppercase letters.

LCASE(stringexpression)

stringexpression: Any string expression.

Example:
    Test = "THE string"
    PRINT Test
    PRINT LCASE(Test); " in lowercase"
    PRINT UCASE(Test); " IN UPPERCASE"


********
* TIME *  (HW dependent)
********
The TIME function returns the computer's current system time.

PRINT TIME


********
* DATE *  (HW dependent)
********
The DATE function returns the computer's current system date.

PRINT DATE


********
* LOG2 *
********
Returns the logarithm base 2 of x.


LOG2(x)


*********
* LOG10 *
*********
Returns the logarithm base 10 of an expression.

LOG10(expression)

expression: Any numeric expression


*********
* HYPOT *
*********
The length of a hypotenuse of a right triangle whose shorter sides are x and y.
In other words, the distance between (0,0) and (x,y).

HYPOT(x,y)

x,y: Any numeric expression


*********
* FLOOR *
*********
Returns the largest integer value less than or equal to a numeric expression.

FLOOR(expression)

expression: Any numeric expression.


********
* CEIL *
********
Returns the smallest integer value greater than or equal to a numeric expression.

CEIL(expression)

expression: Any numeric expression


********
* FMOD *
********
Returns the remainder of x/y.

FMOD(x,y)

NOTE: See also the operator %


*******
* RND *
*******
RND returns a single-precision random number between 0 and 1.

RND(n)

n: A value that sets how RND generates the next random number:

n                              RND returns
---------------------------    ---------------------------
Less than 0                    The same number for any n
Greater than 0 (or omitted)    The next random number
0                              The last number generated


*********
* ETYPE *
*********
Returns the type of an expression.

ETYPE(expression)

Returns 1 in case of a numeric expression, 2 if string expression.


*********
* CHDIR *
*********
CHDIR changes a drive's default directory.

PRINT CHDIR(pathname)

pathname: The path of the new default directory.

CHDIR returns 0 if successful, -1 if failed.


*********
* RMDIR *
*********
RMDIR removes a subdirectory.

PRINT RMDIR(pathname)

pathname: The path of the subdirectory to remove.

RMDIR returns 0 if successful, -1 if failed.


*********
* MKDIR *
*********
MKDIR creates a subdirectory.

PRINT MKDIR(pathname)

pathname: The path of the new subdirectory to create.

RMDIR returns 0 if successful, -1 if failed.


*******
* COL * (HW dependent)
*******
Returns the current column where the cursor is located.

PRINT COL


*******
* ROW * (HW dependent)
*******
Returns the current row where the cursor is located.

PRINT ROW


********
* COLS * (HW dependent)
********
COLS returns the ammount of columns available in the current video mode

PRINT COLS


********
* ROWS * (HW dependent)
********
ROWS returns the ammount of lines available in the current video mode

PRINT ROWS


************
* COPYTEXT * (HW dependent)
************
Copy a block of text to a new position on the screen.

COPYTEXT(left, top, right, bottom, destleft, desttop)

left: Left upper corner of the text to move.
top: Top line of the text to move.
right: Right most column of the text to move.
bottom: Bottom line of the text to move.
destleft: Start column of the new position of the text.
desttop: Start line of the new position of the text.

COPYTEXT returns 1 on success, 0 on error.


***********
* GETTEXT * (HW dependent)
***********
Retrieve a block of screen characters.

GETTEXT(left, top, right, bottom)

left: Top left corner of the text area.
top: Top line of the text area.
right: Bottom right corner of the text area.
bottom: Bottom line of the text area.

GETTEXT will return the captured text as a string. Note that only printable chars
will be returned, text attribute and special chars like carriage return will not
be part of the captured text.

NOTE: Due to the limitiation of 255 chars maximum in MBASIC string variables, you
should guarantee the captured text will not superseed this ammount.

Example:

LOCATE 5,5
PRINT "This is a text"
LOCATE 6,5
PRINT "Some more text"

a = GETTEXT(5,5,14,6)
LOCATE 19,5
PRINT "Below you can see the captured text"
LOCATE 20,5
PRINT a

END


**********
* RENAME *
**********
Renames a file on disk

RENAME(oldname, newname)

oldname: The current file name on disk.
newname: The new file name.


********
* KILL *
********
Deletes files from disk.

KILL(filename)

filename: file to be deleted.


*******
* LOC *
*******
Returns the current position within a file.

LOC(filenumber)

filenumber: The index number of an open file.

For random-access files, LOC returns the number of the last record read
from or written to the file. For sequential files, LOC returns the current
byte position in the file.


*******
* LOF *
*******
Returns the length of a file in bytes.

LOF(filenumber)

filenumber: The index number of an open file.

Example:
    INPUT "Enter filename: "; f$
    OPEN f$ FOR READING,SEQUENTIAL AS #1
    PRINT "File length = "; LOF(1)
    CLOSE #1


*******
* EOF *
*******
Returns 1 if end of a file is reached, 0 otherwise.

EOF(filenumber)

filenumber: The index number of an open file.

Example:
   INPUT "Enter filename: "; f$
   OPEN f$ FOR READING,SEQUENTIAL AS #1
10 FINPUT #1,$STR_VAL
   PRINT STR_VAL NONEWLINE
   IF (EOF(1) = FALSE) THEN GOTO 10
   CLOSE #1


*********
* INSTR *
*********
Returns the position of the first occurrence of a string in another string.

INSTR(start, stringexpression1, stringexpression2)

start: Sets the character position where the search begins.
stringexpression1: The string to search.
stringexpression2: The string to look for.

Example:
    a = "Andre Murta's MBasic"
    PRINT "String position ="; INSTR(1, a, "MBasic")


*******
* SPC *
*******
Skips a specified number of spaces in a PRINT or FPRINT statement.

SPC(n)

n: The number of spaces to skip.

Example:
    PRINT "Text1"; SPC(10); "Text2"


*******
* TAB *
*******
Moves the text cursor to a specified print position.

TAB(column)

column: The column number of the new print position.

Example:
    PRINT TAB(25); "Text"

