public interface EngineApi
This interface defines the native methods that can be used to embed ScriptBasic into applications. Using the methods of this API you can load, execute BASIC programs, define how the interpreter can get access to other sources that are included by the script, set and get global variables and call subroutines.
| Modifier and Type | Method and Description |
|---|---|
Object |
call(String subroutineName,
Object... args) |
void |
eval(File sourceFile)
Evaluate the content of a file.
|
void |
eval(Reader reader)
Read the content of a stream provided by the reader and interpret this as
a BASIC program.
|
void |
eval(String sourceCode)
Evaluate a string as a BASIC program.
|
void |
eval(String sourceFileName,
SourcePath path)
Read the content of the file and execute it.
|
void |
eval(String sourceName,
SourceProvider provider)
Read the content of the source from the file, db...
|
void |
eval(String sourceFileName,
String... path)
Read the content of the file and execute it.
|
void |
execute()
Execute a previously loaded code.
|
Factory |
getBasicFactory()
Get the factory used to create the different parts of the execution
environment for this engine.
|
Writer |
getError()
Get the output writer used to write the error output of the BASIC
program.
|
Reader |
getInput()
Get the reader from where the BASIC program reads the standard input
characters.
|
int |
getNumberOfArguments(String subroutineName) |
Writer |
getOutput()
Get the output writer used to write the standard output of the BASIC
program.
|
Subroutine |
getSubroutine(String subroutineName) |
Iterable<String> |
getSubroutineNames() |
Iterable<Subroutine> |
getSubroutines() |
Object |
getVariable(String name) |
Iterable<String> |
getVariablesIterator() |
void |
load(File sourceFile)
Evaluate the content of a file.
|
void |
load(Reader reader)
Read the content of a stream provided by the reader and interpret this as
a BASIC program.
|
void |
load(String sourceCode)
Load a string as a BASIC program.
|
void |
load(String sourceFileName,
SourcePath path)
Read the content of the file and execute it.
|
void |
load(String sourceName,
SourceProvider provider)
Read the content of the source from the file, db...
|
void |
load(String sourceFileName,
String... path)
Read the content of the file and execute it.
|
void |
setError(Writer error)
Set the output writer used to write the error output of the BASIC
program.
|
void |
setInput(Reader input)
Set the reader from where the BASIC program reads the standard input
characters.
|
void |
setOutput(Writer output)
Set the output writer used to write the standard output of the BASIC
program.
|
void |
setVariable(String name,
Object value) |
Factory getBasicFactory()
If ever you need to use this method, do use it at your own risk, and inform the developers of your need so that they may consider extending this facade to accommodate your needs.
Reader getInput()
void setInput(Reader input)
input - Writer getOutput()
void setOutput(Writer output)
output - Writer getError()
void setError(Writer error)
output - void load(String sourceCode) throws ScriptBasicException
sourceCode - contains the source code as stringScriptBasicExceptionvoid load(Reader reader) throws ScriptBasicException
reader - the reader to supply the BASIC program characters.ScriptBasicExceptionvoid load(File sourceFile) throws ScriptBasicException
sourceFile - the file handler pointing to the file that the interpreter
will read to get the source code.ScriptBasicExceptionvoid load(String sourceFileName, String... path) throws ScriptBasicException
sourceFileName - the file that contains the scriptpath - the array of path elements that are searched for included
filesScriptBasicExceptionvoid load(String sourceFileName, SourcePath path) throws ScriptBasicException
sourceFileName - the file that contains the scriptpath - the path where included files are locatedScriptBasicExceptionvoid load(String sourceName, SourceProvider provider) throws ScriptBasicException
sourceName using the provider. This method does not
execute the code.sourceName - the name of the source file where the source is. The syntax of
the name depends on the provider.provider - the source provider that helps the reader to read the contentScriptBasicExceptionvoid eval(String sourceCode) throws ScriptBasicException
sourceCode - contains the source code as stringScriptBasicExceptionvoid eval(Reader reader) throws ScriptBasicException
reader - the reader to supply the BASIC program characters.ScriptBasicExceptionvoid eval(File sourceFile) throws ScriptBasicException
sourceFile - the file handler pointing to the file that the interpreter
will read to get the source code.ScriptBasicExceptionvoid eval(String sourceFileName, String... path) throws ScriptBasicException
sourceFileName - the file that contains the scriptpath - the array of path elements that are searched for included
filesScriptBasicExceptionvoid eval(String sourceFileName, SourcePath path) throws ScriptBasicException
sourceFileName - the file that contains the scriptpath - the path where included files are locatedScriptBasicExceptionvoid eval(String sourceName, SourceProvider provider) throws ScriptBasicException
sourceName using the provider.sourceName - the name of the source file where the source is. The syntax of
the name depends on the provider.provider - the source provider that helps the reader to read the contentScriptBasicExceptionvoid execute()
throws ScriptBasicException
ScriptBasicExceptionvoid setVariable(String name, Object value) throws ScriptBasicException
ScriptBasicExceptionObject getVariable(String name) throws ScriptBasicException
ScriptBasicExceptionSubroutine getSubroutine(String subroutineName) throws ScriptBasicException
ScriptBasicExceptionIterable<Subroutine> getSubroutines()
Object call(String subroutineName, Object... args) throws ScriptBasicException
ScriptBasicExceptionint getNumberOfArguments(String subroutineName) throws ScriptBasicException
ScriptBasicExceptionCopyright © 2012 Verhas and Verhas Software Craftsmen. All Rights Reserved.