This version of $, can be embedded in a Windows or Linux application with a number of methods for interfacing and interacting with it.
There are three basic methods, demonstrated by the test code.
1 By string based command lines.
2 By reading and writing to the Script Engine's Tables.
3 By linking Script Engine variables directly to Host variables (The most efficient).
The Zip file below, contains test code and headers for FreeBasic and Powerbasic and a DLL for Windows.
The source code, written in FreeBasic is also included, but not annotated (yet!)
The test script "main.pro" looks like this:
' $ script for testing $ script interface
' 22 Aug 2007
' Charles E V Pegge
|
function main() | starting function
state() | obtain state of engine including index of next available
| local variable @16
new longs,singles,zstring |
set @10=2; @16 | trigger a suspension at then end of this line and return @16
| which provides the index for linking to our local variables.
|
singles[1]? | verify that we have a link
set @15=singles[1] | copy this value back to @15 to verify that host can also read our
| variable tables directly
set ++singles[1]++ | pre and pot increment this variable
set singles[1]+=4.5 | then add 4.5 to it
singles[1]? | show the result (in console and log.txt)
end function |
|
function make_upper() | this is a test to see if the host can insert command strings
| during suspension, then get them executed when the script engine
| resumes
set zstring=upper(zstring) | Convert this host string to uppercase
|
end function |
The Zip below contains the Linux equivalent of the $ DLL, compiled in FreeBasic under Mandriva2007 (Mandrake Linux)
called: lib$.so
To make it visible to your application in Linux, it needs to be copied into /lib or /usr/lib.
To place it there you will normally need the top level / root access rights.
This is unlikely but first please ensure that any file of this name will not be overwritten in your system!