Copyright (C) 1998-2005 MKTMK Moscow, Russia

http://www.mktmk.narod.ru.

e-mail: mktmk <at> narod.ru

 

The brief user’s guide of methods and enumerations of interpreter Open Basic

 

1.      Enumerations

 

1.    enum typeload {OVERLAY, NOOVERLAY}; enumeration defines  type of loading.

 

Used in method "load" and method "clrtabl" as argument.

 

At typeload == NOOVERLAY at loading there is a clearing of all tables of the interpreter, except for the table of the user functions.

 

At typeload == OVERLAY at loading there is a clearing of all tables of the interpreter, except for the table of the user functions, the table of variables and the table of arrays.

 

 

2.    enum step {NOSTEP, STEP}; enumeration defines type of start.

 

At step == STEP the method "run" is finished with exit code EOLEND after execute of each line of *.bas-program.

 

At step == NOSTEP the method "run" is not finished after execute of each line of *.bas-program.

 

3.    enum typeend {DUMMYEND, ENDFILEEND, ENDOPERATORDETECT, EOLEND, BREAKPOINTEND, NOLOADEND, BREAKBEFOREOPERATOR, BREAKAFTEROPERATOR}; enumeration defines  the exit code of method "run".

 

-      typeend=DUMMYEND - at normal work never returns by method "run." It is used for internal transitions.

-      typeend=ENDFILEEND the method "run" has terminated because found end input stream. This normal end of *.bas-program

-      typeend=ENDOPERATORDETECT the method "run" has terminated by detect of operator END. This normal end of *.bas-program

-      typeend=EOLEND the method "run" has terminated after execution  of the next line since the flag step=STEP by a method "setstep" was established

-      typeend=BREAKPOINTEND the method "run" has terminated after reading a symbol "@” which is a symbol of breakpoint for Open Basic

-      typeend=NOLOADEND the method "run" has terminated because the method "load" was not executed and the input stream is not open

-      typeend=BREAKBEFOREOPERATOR - the method "run" has terminated before execute some operator OB

-      typeend=BREAKAFTEROPERATOR - the method "run" has terminated after execute some operator OB

 

4.    enum ob_type_ident {OB_IDENTFLO, OB_IDENTINT, OB_IDENTSTR, OB_NOIDENT}; enumeration defines  type of variable Open Basic. Enumeration is not a member of class ob_obasic.

 

2.      Methods

 

 

1.    ob_obasic (istream* i=OB_NULL, ostream* o = and cout, istream* read = and cin);

 

Constructor of interpreter.

 

Parameters:

 

-      i -  input stream (This is *.bas program). It should be open in ios::binary mode

 

-      o  -  output stream for operator PRINT. It should be open in ios::text mode

 

-      read -  input stream of operator INPUT. It should be open in ios::binary mode

 

 

2.    Method static const ob_type_char* about ()

 

Returns “about” string. The string can contain new line symbols.

 

 

3.    Method void load (istream* i, typeload a=ob_obasic:: NOOVERLAY);

 

Loads the *.bas-program into the interpreter.

 

 

4.    Method typeend run ();

 

Starts the loaded *.bas-program.

 

 

5.    Method void setstep (step ts)

 

Establishes a mode of step-by-step execution of the *.bas-program.

 

 

6.    Method step getstep () const

 

Returns the current mode of step-by-step execution.

 

 

7.    Method ob_type_ident typevar (ob_type_char* name)

 

Returns type of variable with a name "name".

 

 

8.    Method ob_type_ident typearray (ob_type_char* name)

 

Returns type of array with a name "name".

 

 

9.    Method void createvar (ob_type_char* name)

 

Creates variable with a name "name" in the table of variables.

 

10.  the Method

 

void createarray (ob_type_char* name, ob_type_arraydimension kr, ob_type_arraysize* as)

 

Creates array with a name "name" in the table of array.

 

 

11.  the Method

 

ob_type_ident strlenvar (ob_type_char* name, ob_type_stringsize* len, ob_type_arraysize* as=OB_NULL)

 

Defines length of string variable or an element of string array.

 

12.  Methods

 

bool

writevar (ob_type_char* name, ob_type_flo val, ob_type_arraysize* as=OB_NULL)

 

bool

writevar (ob_type_char* name, ob_type_int val, ob_type_arraysize* as=OB_NULL)

 

bool

writevar (ob_type_char* name, ob_type_char* val, ob_type_arraysize* as=OB_NULL)

 

 

Assign value "val" to variable or elements of array with a name "name".

 

13.  Methods

 

bool

readvar (ob_type_char* name, ob_type_flo* val, ob_type_arraysize* as=OB_NULL)

 

bool

readvar (ob_type_char* name, ob_type_int* val, ob_type_arraysize* as=OB_NULL)

 

bool

readvar (ob_type_char* name, ob_type_char* val, ob_type_arraysize* as=OB_NULL)

 

 

Read values from variables or from elements of array with a name "name" and assign these values to "val".

 

14.  Method const ob_type_arraysize* getarraysize (ob_type_char* name, ob_type_arraydimension* kr)

 

Allows to define amount of dimention and size of each dimention of array with a name "name".

 

 

15.  Methods

 

bool setfun (ob_type_char* name, ob_type_flofun f)

 

bool setfun (ob_type_char* name, ob_type_intfun f)

 

bool setfun (ob_type_char* name, ob_type_charfun f, ob_type_del dt)

 

Connect the user function with a name "name" to execution system of interpreter Open Basic.

 

 

16.  Method bool delfun (ob_type_char* name)

 

Disconnects the user function with a name "name" from execution system of interpreter Open Basic.

 

 

17.  Method static const ob_type_serialnum serial_number ()

 

Returns number of copy of the program.

 

18.  Method static const ob_type_int version ()

 

Returns number of version of the program multiply by 100. For version 1.50 returns number 150.

 

19.  Method void clrtabl (typeload a=NOOVERLAY)

 

Clears all tables of the interpreter, except for the table of the user functions.

 

20.  Method void clrtablfun ()

 

Clears the table of the user functions of the interpreter.

 

 

21.  Method

 

bool setoperatorbreak (char* name, ob_operator:: flbreak b, ob_operator:: flbreak a);

 

Establishes mode of the ending of method "run" before or after execute of the operator with a name "name" It is used for interface of input-output operators PRINT and INPUT to operation system.

 

22.  Method ob_type_char* getcurrentoperatorname ()

 

Returns name of last executed operator.

 

23.  Method void setout (ostream* o)

 

Establishes a new stream of a conclusion, instead of given in constructor. The stream should be open in ios::text mode. It is used for interface of input-output operators PRINT and INPUT to operation system.

 

 

24.  Method void setin (istream* i)

 

Establishes a new stream of input, instead of given in constructor. The stream should be open in ios::binary mode. It is used for interface of input-output operators PRINT and INPUT to operation system.

 

25.  Method ob_lex:: typelex gettypenextlex ()

 

Returns the following lexeme from an input stream. It is used for interface of input-output operators PRINT and INPUT to operation system. After application of this method the status of a stream should be restored by method restoreinputpointer ().

 

26.  Method void restoreinputpointer ()

 

It is used for restore of status of input stream after use method gettypenextlex ().