Press on the image to return to the main documentation page.
Basiclib
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.
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.
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 (nameAsString, 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 (nameAsString) AsBoolean
Return true if the named Sub exists in subptrs
dbgGlobal (idAsInt) AsString
Returns the name of a global variable given its numeric ID. This is provided for debugging the tokeniser and execution engine.
dbgLiteral (idAsInt) AsString
Returns the name of a program literal value given its numeric ID. This is provided for debugging the tokeniser and execution engine.
dbgLocal (subAsString, idAsInt) 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.
dbgTokenCountAsInt [read only]
Returns the total number of tokens in the compiled program. This is provided for debugging the tokeniser and execution engine.
dbgTokenName (tokenvalueAsInt) AsString
Returns the name of a token given its numeric value. This is provided for debugging the tokeniser and execution engine.
dbgTokenNameAt (indexAsInt) AsString
Returns the token name at position index in the compiled program. This is provided for debugging the tokeniser and execution engine.
dbgTokensAsString [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 (tokennameAsString) 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 (indexAsInt) AsInt
Returns the token value at position index in the compiled program. This is provided for debugging the tokeniser and execution engine.
ErrorStringAsString [read only]
Gets a description of any error that occurred while the program was executing or an empty string if there was no error.
FinishedAsBoolean [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 (varAsString) AsString()
Returns a reference to a copy of the B4Script array specified. This is valid only after the Starting event has occurred.
GetArrayItem (varAsString, indexAsInt) AsString
Returns the item at index position in the B4Script array specified. This is valid only after the Starting event has occurred.
GetArrayLength (varAsString) AsInt
Returns the number of items in the B4Script array specified. This is valid only after the Starting event has occurred.
GetGlobal (varAsString) AsString
Returns the value of the B4Script global variable specified. This is valid only after the Starting event has occurred.
GetLocal (varAsString) 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 (eventnameAsString)
LineNumberAsInt [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 (programAsString) 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.
MessageStringAsString [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 (linenumberAsInt) AsString
Returns the source code of the program for the line number specified.
ProgramLinesAsInt [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 (varAsString, vals() AsString)
Sets the global array named var to a copy of the array vals.
Sets the contents of the item index of the global array named var to val.
SetGlobal (varAsString, valAsString)
Sets the contents of the global variable named var to val.
SetLocal (varAsString, valAsString)
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 (varAsString, 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.
StackDepthAsInt [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.
SubjectStringAsString [read only]
Gets the the subject of the last Msgbox statement or "Print" if the last statement was a Print statement.