Android Programming Press on the image to return to the main documentation page.

BasicLibIDE

Written by Andrew Graham

This library includes an object that can execute scripts written in the B4Script language.
B4Script is a runtime scripting language intended for incorporation into applications
written using Basic4ppc and Basic4Android. It is a sub-set of the full Basic4ppc language
with only minor variations in syntax.

This version of the library is intended to work with an application including the Script.bas
Basic4android module to implement a device based IDE. Script.bas includes platform functions
which are callable as normal language functions from this language in contrast to the usual BasicLib
library which has no platform knowledge and relies upon the SYS or CALLHOSTSUB functions
to access underlying host functions. SYS or CALLHOSTSUB are of course available in this library in case of need.

The version number of this library should match that of Script.bas modoule it is compiled into,

Basic4Android and Basic4ppc are products of Anywhere Software and details may be found at
http://www.basic4ppc.com

List of types:

BasicLibIDE

BasicLibIDE

This class contains a B4Script interpreter. See the separate B4Script documentation
for the language details and the BasicLibIDEhelp documentation for the supported platform functions.

Events:

Break(linenumber As Int) 'The script has stopped at linenumber
Loaded(error As String) 'Error is an empty string if the script loaded without error
Starting 'The script has initialised its variables and is about to start executing
Stepped(linenumber As Int) 'The script has stepped to linenumber
Message(message As String, subject As String) 'Raised by Msgbox or Print
Ended(error As String) 'Error is an empty string if the script terminated without error

Members:


  BreakAtLine As Int

  Call (name As String, params() As StringAs String

  CanCall (name As StringAs Boolean

  dbgGlobal (id As IntAs String

  dbgLiteral (id As IntAs String

  dbgLocal (sub As String, id As IntAs String

  dbgTokenCount As Int  [read only]

  dbgTokenName (tokenvalue As IntAs String

  dbgTokenNameAt (index As IntAs String

  dbgTokens As String  [read only]

  dbgTokenValue (tokenname As StringAs Int

  decTokenValueAt (index As IntAs Int

  ErrorString As String  [read only]

  Finished As Boolean  [read only]

  GetArray (var As StringAs String()

  GetArrayItem (var As String, index As IntAs String

  GetArrayLength (var As StringAs Int

  GetGlobal (var As StringAs String

  GetLocal (var As StringAs String

  Halt

  Initialize (eventname As String)

  LineNumber As Int  [read only]

  LoadCodeAsArray (program() As StringAs Boolean

  LoadCodeAsString (program As StringAs Boolean

  MessageString As String  [read only]

  Program() As String  [read only]

  ProgramLine (linenumber As IntAs String

  ProgramLines As Int  [read only]

  Run (args() As StringAs Boolean

  SetArray (var As String, vals() As String)

  SetArrayItem (var As String, index As Int, val As String)

  SetGlobal (var As String, val As String)

  SetLocal (var As String, val As String)

  ShareArray (var As String, vals() As String)

  StackDepth As Int  [read only]

  Step As Boolean

  SubjectString As String  [read only]

  Version As Double  [read only]

Members description:

BreakAtLine As Int
Gets or sets the line number at which execution will cause the Break event to be raised.
A value of 0 disables Break.
Call (name As String, params() As StringAs String
Calls the Sub name in the presently loaded program passing it the parameters values
provided and returns the return value of the Sub, which may in turn call others.
The reason for any failure will be in the ErrorString property.
It is only valid to do this after the Starting event has occurred.
CanCall (name As StringAs Boolean
Return true if the named Sub exists in subptrs
dbgGlobal (id As IntAs String
Returns the name of a global variable given its numeric ID.
This is provided for debugging the tokeniser and execution engine.
dbgLiteral (id As IntAs String
Returns the name of a program literal value given its numeric ID.
This is provided for debugging the tokeniser and execution engine.
dbgLocal (sub As String, id As IntAs String
Returns the name of a local variable given the Sub name in which it is used and its numeric ID.
This is provided for debugging the tokeniser and execution engine.
dbgTokenCount As Int  [read only]
Returns the total number of tokens in the compiled program.
This is provided for debugging the tokeniser and execution engine.
dbgTokenName (tokenvalue As IntAs String
Returns the name of a token given its numeric value.
This is provided for debugging the tokeniser and execution engine.
dbgTokenNameAt (index As IntAs String
Returns the token name at position index in the compiled program.
This is provided for debugging the tokeniser and execution engine.
dbgTokens As String  [read only]
Returns a string that contains the tokenised version of the program which is what the BasicLib execution engine interprets.
This is provided for debugging the tokeniser and execution engine.
dbgTokenValue (tokenname As StringAs Int
Returns the numeric value of a token given its name as a string.
This is provided for debugging the tokeniser and execution engine.
decTokenValueAt (index As IntAs Int
Returns the token value at position index in the compiled program.
This is provided for debugging the tokeniser and execution engine.
ErrorString As String  [read only]
Gets a description of any error that occurred while the program was executing
or an empty string if there was no error.
Finished As Boolean  [read only]
Returns True if the program has finished executing.
This is of little use in a single threaded situation but might be of use if the program is being run on a thread.
GetArray (var As StringAs String()
Returns a reference to a copy of the B4Script array specified.
This is valid only after the Starting event has occurred.
GetArrayItem (var As String, index As IntAs String
Returns the item at index position in the B4Script array specified.
This is valid only after the Starting event has occurred.
GetArrayLength (var As StringAs Int
Returns the number of items in the B4Script array specified.
This is valid only after the Starting event has occurred.
GetGlobal (var As StringAs String
Returns the value of the B4Script global variable specified.
This is valid only after the Starting event has occurred.
GetLocal (var As StringAs String
Returns the value of the B4Script local variable specified.
The local variable returned is that of the present execution context.
i.e. that belonging to the current Sub.
If called while execution is in the main code block a global variable is returned if one with the name var exists.
Halt
Stops the program when it reaches the end of the next statement.
The Ended event will fire.
The line number of the last statement executed may be found in the LineNumber property.
The program cannot be resumed once halted but must be restarted if required to run again.
This method may be used stop a program if it gets stuck in an endless loop for some reason.
If this is called within a Break or Stepped event the program will halt as soon as the event code returns.
Initialize (eventname As String)
LineNumber As Int  [read only]
Returns the line number of the next program line to be executed.
LoadCodeAsArray (program() As StringAs Boolean
Loads the script represented by the contents of the specified String array.
Each element of the array contains one line of the script.
Returns True if the program loaded properly otherwise returns False.
The reason for failure will be in the ErrorString property.
LoadCodeAsString (program As StringAs Boolean
Loads the script represented by contents of the specified string.
Each line of the string followed by CRLF contains one line of the script.
Returns True if the program loaded properly otherwise returns False.
The reason for failure will be in the ErrorString property.
MessageString As String  [read only]
Gets the the content of the last Msgbox statement or the result of the last Print statement.
Program() As String  [read only]
Returns an array of strings containing the program with one program line in each array element.
ProgramLine (linenumber As IntAs String
Returns the source code of the program for the line number specified.
ProgramLines As Int  [read only]
Gets the number of source code lines in the program.
Run (args() As StringAs Boolean
Runs the presently loaded program again and returns True if the program ran and ended properly otherwise returns False.
The reason for failure will be in the ErrorString property.
args is an array that may be used to pass arguments to the program to be run.
SetArray (var As String, vals() As String)
Sets the global array named var to a copy of the array vals.
SetArrayItem (var As String, index As Int, val As String)
Sets the contents of the item index of the global array named var to val.
SetGlobal (var As String, val As String)
Sets the contents of the global variable named var to val.
SetLocal (var As String, val As String)
Sets the contents of the local variable named var to val.
The local variable assigned is that of the present execution context.
i.e. that belonging to the current Sub.
If called while execution is in the main code block a global variable is assigned if one with the name var exists.
ShareArray (var As String, vals() As String)
Sets the global array named var to the array vals.
Unlike GetArray and SetArray which make a copy the specified array is now shared by the main program and the script and changes made by one will be seen by the other.
StackDepth As Int  [read only]
Gets or sets the size of the call and loop stacks.
This determines how many sub-routine calls, For/Do loops or If statements can be nested.
The default is five.
Step As Boolean
Gets or sets the state of the Step flag.
If set True then the program executes one line at a time raising the Stepped event at the end of each line.
SubjectString As String  [read only]
Gets the the subject of the last Msgbox statement or "Print" if the last statement was a Print statement.
Version As Double  [read only]
Returns the version number of the library.
Top