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
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
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 AsString, params() AsString) AsString
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 AsString) AsBoolean
Return true if the named Sub exists in subptrs
dbgGlobal (id AsInt) AsString
Returns the name of a global variable given its numeric ID. This is provided for debugging the tokeniser and execution engine.
dbgLiteral (id AsInt) AsString
Returns the name of a program literal value given its numeric ID. This is provided for debugging the tokeniser and execution engine.
dbgLocal (sub AsString, id AsInt) AsString
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 AsInt [read only]
Returns the total number of tokens in the compiled program. This is provided for debugging the tokeniser and execution engine.
dbgTokenName (tokenvalue AsInt) AsString
Returns the name of a token given its numeric value. This is provided for debugging the tokeniser and execution engine.
dbgTokenNameAt (index AsInt) AsString
Returns the token name at position index in the compiled program. This is provided for debugging the tokeniser and execution engine.
dbgTokens AsString [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 AsString) AsInt
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 AsInt) AsInt
Returns the token value at position index in the compiled program. This is provided for debugging the tokeniser and execution engine.
ErrorString AsString [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 AsBoolean [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 AsString) AsString()
Returns a reference to a copy of the B4Script array specified. This is valid only after the Starting event has occurred.
GetArrayItem (var AsString, index AsInt) AsString
Returns the item at index position in the B4Script array specified. This is valid only after the Starting event has occurred.
GetArrayLength (var AsString) AsInt
Returns the number of items in the B4Script array specified. This is valid only after the Starting event has occurred.
GetGlobal (var AsString) AsString
Returns the value of the B4Script global variable specified. This is valid only after the Starting event has occurred.
GetLocal (var AsString) AsString
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 AsString)
LineNumber AsInt [read only]
Returns the line number of the next program line to be executed.
LoadCodeAsArray (program() AsString) AsBoolean
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 AsString) AsBoolean
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 AsString [read only]
Gets the the content of the last Msgbox statement or the result of the last Print statement.
Program() AsString [read only]
Returns an array of strings containing the program with one program line in each array element.
ProgramLine (linenumber AsInt) AsString
Returns the source code of the program for the line number specified.
ProgramLines AsInt [read only]
Gets the number of source code lines in the program.
Run (args() AsString) AsBoolean
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 AsString, vals() AsString)
Sets the global array named var to a copy of the array vals.
SetArrayItem (var AsString, index AsInt, val AsString)
Sets the contents of the item index of the global array named var to val.
SetGlobal (var AsString, val AsString)
Sets the contents of the global variable named var to val.
SetLocal (var AsString, val AsString)
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 AsString, vals() AsString)
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 AsInt [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.
StepAsBoolean
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 AsString [read only]
Gets the the subject of the last Msgbox statement or "Print" if the last statement was a Print statement.