PDA

View Full Version : Using Oxygen as a general DLL



Charles Pegge
14-06-2009, 12:53
I have made the Oxygen functions exportable so they are accessible when it is used as a DLL as well as being used as a thinBasic module.

Future modules written in Oxygen will use this DLL interface for their runtime services.

Charles





'-----------------------
'OXYGEN AS A GENERAL DLL
'=======================


'SELECTED API
'------------
'
declare sub o2_asmo lib "thinbasic_oxygen.dll" alias "o2_asmo" (byval s as string)
declare sub o2_basic lib "thinbasic_oxygen.dll" alias "o2_basic" (byval s as string)
declare function o2_buf lib "thinbasic_oxygen.dll" alias "o2_buf" (byval n as long) as long
declare function o2_error lib "thinbasic_oxygen.dll" alias "o2_error" () as string
declare function o2_exec lib "thinbasic_oxygen.dll" alias "o2_exec" (optional byval p as long) as long
declare function o2_get lib "thinbasic_oxygen.dll" alias "o2_buf" () as string
declare function o2_len lib "thinbasic_oxygen.dll" alias "o2_len" () as long
declare function o2_prep lib "thinbasic_oxygen.dll" alias "o2_prep" (byval srcBSTR as string) as string
declare sub o2_put lib "thinbasic_oxygen.dll" alias "o2_buf" (byval c as string)
declare function o2_view lib "thinbasic_oxygen.dll" alias "o2_view" (byval srcBSTR as string) as string

dim src as string

src = "
#o2h
print `ok`
terminate
"


'msgbox 0, o2_prep src
'msgbox 0, o2_view src

o2_basic src

'msgbox 0,o2_len
'msgbox 0,o2_buf 0


if len(o2_error) then
msgbox 0, o2_error() : stop
end if

o2_exec

jcfuller
14-06-2009, 18:20
Charles,
Does this mean you can use Oxygen outside of ThinBasic??

James

Charles Pegge
14-06-2009, 22:32
Hi James,

We can do this already with low level Oxygen but there are a few minor entanglements to sort out before Oxygen Basic can be used independently. And most important of all will be the ability to read the full MS Windows API header set, - José Roca's or FreeBasic's.

Oxygen can then be deployed as a DLL of about 300k to accompany compiled DLLs / EXEs / Naked binaries / Source code in an application.

I'm relying on it's small size to make rapid progress.

Charles

kryton9
15-06-2009, 07:13
Sounds very exciting Charles! Thanks.

Charles Pegge
25-06-2009, 00:26
This is the first thinBasic Module to be written in Oxygen Basic. To run the module maker script, It requires the PowerBasic version of thincore.inc which you will normally find in \thinBasic\sdk\sdk ... but I have included it in the zip below.

It compiles a module called thinBasic_z.dll.

Latest Pxygen Download: http://community.thinbasic.com/index.php?topic=2517


Test Script


'---------------------------
'thinBasic Modules in Oxygen
'===========================

uses "z"
msgbox 0,greet "World"




Module Maker Script


uses "oxygen"

'---------------------------
'thinBasic Modules in Oxygen
'===========================


dim src as string


src = "


' ####
' ########
' ## ###
' ## ### ####
' ## ## ##
' ### ### ##
' ######## ##
' #### ##
' ######

#basic
#file `thinBasic_z.dll`
include `thincore.inc`

'-------------------------------------------------
function greet alias `greet` () as string external
'=================================================

dim As Long ParensPresent
ParensPresent = thinBasic_CheckOpenParens_Optional
dim as string s=`you`
dim as double d=thinBasic_parseString(s)
If ParensPresent Then thinBasic_CheckCloseParens_Mandatory
function=`Hello ` s
end function

'----------------------------------------------------------------------------------------------
function LoadLocalSymbols Cdecl ALIAS `LoadLocalSymbols` (BYVAL sPath AS STRING) AS Long export
'==============================================================================================
thinBasic_LoadSymbol `greet`,thinBasic_ReturnString, &greet, thinBasic_ForceOverWrite
function = 0
end function

'--------------------------------------------------------------------------------------------------
function UnLoadLocalSymbols Cdecl ALIAS `UnLoadLocalSymbols` (BYVAL sPath AS STRING) AS Long export
'==================================================================================================
function=0
end function

'--------------------
sub finish() external
'====================
'print `finish`
terminate
end sub


"

' ##### ###### ###### ###### ###
' ######## ######### ######### ######### #####
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ## ## ## ## ## ## ## ##
' ## ########## ########## ########## ##########
' # ###### ###### ###### ######
'
'


o2_asmo src


if len(o2_error) then
msgbox 0, "ERROR:"+$cr+o2_error()
else
msgbox 0,"COMPILED OK"
end if

Lionheart008
25-06-2009, 10:38
hi charles :)

short: I am at school at the moment... have tried your module-maker script example this early morning... and I have got an error message for "testZmodule.tbasic" script... or I have done something wrong with installation, but I am nearly sure.. I have done everything in the right way... can you check it again or say me, what I have done wrong by testing... ? :)

good luck for further developments with oxygen module maker ! 8)

nice to see: my first dll experiments belongs to the lionmodule I have made end of may... so after one month of getting new knowledge by practical works it's like a new friend with some strange behaviour that I like a lot to me :)

can only say: module maker is simply great!!! :D

... best regards, Frank

Charles Pegge
25-06-2009, 11:20
Hi Frank,

It may be because the module cannot locate oxygen for its own operations. I have just added another line of code to ensure that the current directory is checked for the latest Oxygen, before looking in \thinbasic\lib.

You could try again with this updated version

http://community.thinbasic.com/index.php?topic=2517

Thanks for testing!

Charles

Petr Schreiber
25-06-2009, 12:20
Hi Charles,

the compilation went fine (file size result is about 3584 bytes), but executing uses "z" causes GPF on my machine.
I suspect it is related to thinCore.inc file including, as whether I have it in directory (same as compiler script or lib) it still produces the same EXE size.

Any ideas?
Petr

Charles Pegge
25-06-2009, 13:00
Hi Petr,

Thanks for checking it over.

Here are some things to try. All you need in one folder - so it does not matter which version of Oxygen resides in \thinbasic\lib\. (I nobbled mine to make sure :) )

Charles

Petr Schreiber
25-06-2009, 13:13
Hi Charles,

interesting but wierd thing occurs to me - when I execute script from drive C (C:\Download\Download2008\TB_O2_compiled\thinBasic_z), no problem. When from drive E (E:\util\thinBasic\UserScripts\Oxycomp), it GPFs :shock:

Charles Pegge
25-06-2009, 14:29
Hi Petr,

I've modified the oxygen DLL searches slighlty, if you would like to try again. It worked from a memory stick on drive k: (thinBasic installed on c:\).

Charles

PS:
the search strategy:

freebasic o2prep.bas


"`thinBasic_Oxygen.dll` : push eax : call [ebx] : cmp eax,0 : jnz fwd ndll"+cr+_
"`.\lib\thinBasic_Oxygen.dll` : push eax : call [ebx] : cmp eax,0 : jnz fwd ndll"+cr+_
"`c:.\lib\thinBasic_Oxygen.dll` : push eax : call [ebx] : cmp eax,0 : jz fwd xdll"+cr+_

Petr Schreiber
25-06-2009, 15:43
Hi Charles,

my PC has some evil forces inside:

from drive C - OK
from drive F - OK
from drive E - GPF

Could it be caused by fact I have installed Windows on drive E instead of C?
(if you are curious why, please resend to Redmond, I do not know why this did happen :D)


Petr

Charles Pegge
25-06-2009, 16:40
Hi Petr,

I am puzzled. Could you try patching the thinBasic_Oxygen.dll directly into your thinBasic\lib\ as well.

Charles

This is what Redmond has to say: (From MSDN)


Search Path Used by Windows to Locate a DLL

With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence:

1.The directory where the executable module for the current process is located.

2.The current directory.

3.The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

4.The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

5.The directories listed in the PATH environment variable.

Petr Schreiber
25-06-2009, 18:29
Hi Charles,

dont know why, but it seems to work now, I deleted all DLLs, moved oxygen to lib ... seems ok now. Very weird.

My Redmond remark was related to why my Windows landed on drive E, not to torture you with explaining DLL locations, but thanks :)

Charles Pegge
25-06-2009, 18:47
Many thanks Petr - I think that explains it - grabbing onto an older version of oxygen on your system. And it has made me pay closer attention to the DLL locating strategy.

I have been pushing DLLs and EXEs around my PC in all sorts of combinations and no surprises so far.

But one minor problem remains: I can only load 3 instances of 4PortViewerB - it usually GPFs on the fourth. But this does not happen when it is run as a thinBasic script - only as an EXE. 4PortViewerA.exe and HelloWin.exe will work with any number of instances.


Charles

Charles Pegge
25-06-2009, 23:28
Found the problem with 4PortViewerB.exe :)

There was a variable mapped to a thinBasic variable



dim a at #a as long


Making it independent prevented the multiple instances GPF.



dim a


So DLL and EXE generation passes all tests so far.

Charles

kryton9
26-06-2009, 00:01
I downloaded the all in one zip a few posts down from the first post. All ran fine except 4PortViewerB.exe. I just get the waiting icon and watch it spin a few times and then it goes away.
But all the other exe's worked!

Charles Pegge
26-06-2009, 00:12
Hi Kent,

Thanks for testing them.

Try dropping this one with the correction into the folder. I will also update the zip posted above.

Charles

zak
01-07-2009, 11:06
Hi
i have tried the Oxygen module yesterday for the first time , i think it is a marvelous module, it is like having an airplane inside a Bus available for passengers on demand,
today i have tried to call the ( thinBasic_Oxygen.dll ) from visual basic 6 and it is succeeded as the following attached code.
from vb6 add a module.bas

Declare Sub o2_asmo Lib "c:\\thinbasic_oxygen.dll" (ByVal s As String)
Declare Sub o2_basic Lib "c:\\thinbasic_oxygen.dll" (ByVal s As String)
Declare Function o2_buf Lib "c:\\thinbasic_oxygen.dll" (ByVal n As Long) As Long
Declare Function o2_error Lib "c:\\thinbasic_oxygen.dll" () As String
Declare Function o2_exec Lib "c:\\thinbasic_oxygen.dll" (Optional ByVal p As Long) As Long
Declare Function o2_get Lib "c:\\thinbasic_oxygen.dll" Alias "o2_buf" () As String
Declare Function o2_len Lib "c:\\thinbasic_oxygen.dll" () As Long
Declare Function o2_prep Lib "c:\\thinbasic_oxygen.dll" (ByVal srcBSTR As String) As String
Declare Sub o2_put Lib "c:\\thinbasic_oxygen.dll" Alias "o2_buf" (ByVal c As String)
Declare Function o2_view Lib "c:\\thinbasic_oxygen.dll" (ByVal srcBSTR As String) As String


then draw a Form with a button "RUN" and attach the following code to the button:

Private Sub Command1_Click()
Dim src As String
src = "print `okay it is called from vb6`"
'src = src & Chr(13) & Chr(10)
o2_basic src
o2_exec

End Sub
i have copied the thinbasic_oxygen.dll to the c:\\ directory so the declare can find it, since using regsvr32 have failed to register it.
when we run the vb6 code and clicking on the run button it will issue the message from oxygen, like the attached picture. this is marvelous.
but i need to know how to attach more code , such as terminate , as i have failed in that in the classic way.
best regards

Charles Pegge
01-07-2009, 11:49
Hi Zak,

I am fascinated you have been able to use Oxygen in VB6. I have never used VB6 myself, so never entertained the possibility.

Ideally we need late binding (to DLLs) so you can manually assign addresses to function calls in VB6. If this is not possible then you can create a DLL compiled in thinBasic. And use it in the conventional way. This will work independently of thinBasic when you include thinBasic_Oxygen.dll in the same folder as the executable.

I'll do some research..

Charles

zak
01-07-2009, 13:20
Hi Charles
yes , i have tried your example "Arithmetic", it is working.
just replace the src = ... in the above code with:

src = " print `Answer ` str 1+2+3+4 : terminate "
and the messageBox from O2 will issue Answer 10
i will try other examples
best wishes

Charles Pegge
01-07-2009, 13:44
Yes single-shot examples,as you have demonstrated, will work fine Zak. I was wondering whether VB would support function pointers to enable several oxygen subs or functions to be called from the same script. Unfortunately it appears that VB6 does not support function pointers - so the only option would be to create a DLL from the oxygen script, exporting the required functions in the classical way.

Charles

zak
01-07-2009, 14:09
Hi Charles
i think there is no function pointers, but i remember there is a "not documented" Ptr function to point for the variables, i will read about it
from your examples also, here is the sum of the numbers from 1 to a million,

src = " dim a as quad : dim i as long: for i=1 to 1000000: a=a+i : next i: Print str a: terminate "
the answer is 500000500000
it is calculated almost instantly

Charles Pegge
01-07-2009, 15:09
Hi Zak,

Do you have the VB6 compiler - or just the interpreter? It would be interesting to compare speed.

BTW: With compiled progs, you would put thinBasic_Oxygen and other local DLLs into the same folder as the EXE. But it is unclear where to put them (by default) for use with interpreted VB6 files.

Charles

zak
01-07-2009, 17:32
Hi Charles
your guess is right, i have changed to an old computer to protect my original one from extremely hot weather and have installed vb6 , also thinbasic beta. i have deleted the "C:\\" from the declarations , the first time i have run the code, it gives me an error,
vb6 within its IDE run in an interpreted way, so as you have said i have compiled it from within the IDE using those options:
compile to native code
optimize for fast code
and with the dll inside the folder it is running ok, the strange thing is that now running the code from within IDE are not producing errors, please download the code and the compiled exe version from googlesites here:
http://sites.google.com/site/zak31415/Home/vb6-o2.rar
i think your dll is Ready for external programs,
tomoroo in the colder weather i will try subs and functionsm and to see if it is possible to convert the Eros Fibonacci code to vb6
regards
the program will add numbers from 1 to ten millions, i love big numbers

zak
01-07-2009, 22:44
Hi Charles, Hi all

after this posting, we will appreciate how much thinbasic have facilities much more than vb6,
here is the main form vb6 code wich will emulate the fibonacci function wich are posted in the Oxygen forum, the declaration module and the time module are compressed within the attached file, also the EXE file, you may need (or not) vb6 runtime sp6

Private Sub Command1_Click()

dtStart = GetTickCount ' start counting time

Dim src As String
Dim n As Integer
n = Text1.Text

src = "FUNCTION fibonacci(byval sequence as Dword) as Dword:"
src = src & "IF sequence < 2 THEN:"
src = src & "FUNCTION = sequence:"
src = src & "Else : FUNCTION = fibonacci(sequence - 1) + fibonacci(sequence - 2):"
src = src & "END IF: END FUNCTION :"
src = src & "print str fibonacci(" & Str(n) & ")" & ":terminate"
o2_basic src
o2_exec

dtEnd = GetTickCount
result = dtEnd - dtStart
MsgBox "Duration is " & result & " milliseconds."

End Sub

in the text box write the suitable number but not more than 40 else the program will hanging, the same sitution in thinbasic program.
the vb6_Oxygen fibonacci(40) time on my pc varied between 3.5 seconds to 4.2 seconds. the time measuring are not correct in vb6
i can't direct the output of o2_exec to a vb6 text box, i will continue the investigation
regards

correction : delete the line src = "dim n as Dword:" from the attached source code, there is no need for it

Charles Pegge
01-07-2009, 23:37
Hi Zak,

This should return the result to VB6 by transferring the result to the eax register just before terminate

dim as long a=fibonacci n : print str a : mov eax,a : terminate

....

v=o2_exec



I hope I have the punctuation right :)

Charles




Private Sub Command1_Click()

dtStart = GetTickCount ' start counting time

Dim src As String
Dim n As Integer
Dim v As Integer
n = Text1.Text

src = "FUNCTION fibonacci(byval sequence as Dword) as Dword:"
src = src & "IF sequence < 2 THEN:"
src = src & "FUNCTION = sequence:"
src = src & "Else : FUNCTION = fibonacci(sequence - 1) + fibonacci(sequence - 2):"
src = src & "END IF: END FUNCTION : "
src = src & "dim as long a=fibonacci(" & Str(n) & ") : print str a : mov eax,a : terminate"
o2_basic src
v=o2_exec

dtEnd = GetTickCount
result = dtEnd - dtStart
MsgBox "Value is " & v & " Duration is " & result & " milliseconds."

End Sub

John Spikowski
02-07-2009, 04:10
Hi Charles,

I would like to give O2 a try with ScriptBasic if you have some time to contribute to a GNU LGPL open source project. ScriptBasic can call a Windows DLL with it's DYC (http://www.scriptbasic.org/forum/index.php/topic,105.0.html) extension module. Most ScriptBasic DLL's / Linux Shared Objects are built as extension modules. I would guess this is true of thinBASIC extension modules as well.

If there is any interest then please let me know and I will reserve some time to work with you on it.


John

zak
02-07-2009, 05:37
Hi Charles
thank you, it is working, but after defining v as double or Long
i can't understand this assembly language
regards

Charles Pegge
02-07-2009, 07:08
Hi John,

Interface for scriptBasic? Yes good idea :)

I have studied your DYC DLL calling spec. This looks quite simple, but I think we need to come up with library functions that do not require BSTRINGs for string buffers - particularly for Linux. Oxygen can return strings of machine code but mostly they are source code where zstrings would suffice.

I can't think of any other obstacles.

Charles

Charles Pegge
02-07-2009, 07:29
Hi Zak,

That little bit of assembly code towards the end of the final line is all you need to return dword or long results.

mov eax,a

To return floating point results - here is a sneaky way:

add to your Declares

Declare Function o2_exec_double Lib "c:\\thinbasic_oxygen.dll" alias "o2_exec" (Optional ByVal p As Long) As double


then:


Private Sub Command1_Click()

dtStart = GetTickCount ' start counting time

Dim src As String
Dim n As Integer
Dim v As double
n = Text1.Text

src = "FUNCTION fibonacci(byval sequence as Dword) as double :"
src = src & "IF sequence < 2 THEN:"
src = src & "FUNCTION = sequence:"
src = src & "Else : FUNCTION = fibonacci(sequence - 1) + fibonacci(sequence - 2):"
src = src & "END IF: END FUNCTION : "
src = src & "dim as double a=fibonacci(" & Str(n) & ") : print str a : fld qword a : terminate"
o2_basic src
v=o2_exec_double

dtEnd = GetTickCount
result = dtEnd - dtStart
MsgBox "Value is " & v & " Duration is " & result & " milliseconds."

End Sub

John Spikowski
02-07-2009, 08:58
Hi John,

Interface for scriptBasic? Yes good idea :)

I have studied your DYC DLL calling spec. This looks quite simple, but I think we need to come up with library functions that do not require BSTRINGs for string buffers - particularly for Linux. Oxygen can return strings of machine code but mostly they are source code where zstrings would suffice.

I can't think of any other obstacles.

Charles



That is great news !

Actually I would like to see a ScriptBasic O2 extension module DLL/SO that could easily interface with the core of ScriptBasic and take full control of execution, memory and even dynamically change syntax on the fly. (like substituting SB functionality for O2 routines if the O2 extension module is included) Check out the SB dev guide (http://www.scriptbasic.org/docs/dg/devguide_toc.html) on extension modules.

This working on both Windows and Linux is just icing on the cake. :eusadance:

This might just be the shot in the arm I needed to spend more time with ScriptBasic rather then BCX. :)

Charles Pegge
02-07-2009, 21:39
Okay John, I will work on the interface functions and provide a zstring/asciiz input for source code.

And when working in the Linux environment - I will have to adopt an alternative to Ole BSTR for dynamic strings.

Charles

Lionheart008
02-07-2009, 23:37
hi charles, hi all :)

@charles: it's possible to make a new thinbasic_z test example like you did it for "greet world" ? for me would be great to see a second function like `greet`.. I have tried it with a simple `formula`and the example was compiled by the oxygen module maker with OK :) but not by the testZmodule thinbasic script...


thinBasic_LoadSymbol `greet`,thinBasic_ReturnString, &greet, thinBasic_ForceOverWrite
function = 0
end function

I have tried it, but without success as I have got some error messages ...

nice evening, cheerio, lionheart

John Spikowski
03-07-2009, 00:38
Okay John, I will work on the interface functions and provide a zstring/asciiz input for source code.

Charles



Outstanding !

I setup a new O2 board (http://www.scriptbasic.org/forum/index.php/board,44.0.html) on the ScriptBasic forum.

It would be great if you could post an intro to O2 for the ScriptBasic folks.



And when working in the Linux environment - I will have to adopt an alternative to Ole BSTR for dynamic strings.


Why not use ScriptBasic's dynamic string functions? Keep in mind that the ScriptBasic variables are typeless. As a ScriptBasic extension module developer, you have full access to the ScriptBasic object like API. (#include "scriba.h")

I will help in any way I can, just ask.

John

Charles Pegge
03-07-2009, 08:17
Hi John, Thanks!

Time is the major limitation, but I like the idea, and it should fit well.

I'll try the scriptBasic's DYC interface first - since that will work with any DLL. To work more directly with scriptBasic , I would customise Oxygen in a similar way to the thinBasic_Oxygen implementation. Only one file is involved.

For dynamic strings , I have abstracted the OLE Bstrings in Oxygen so all I need to do is hitch 2 functions to the Linux Kernel, replacing sysAllocStringByteLen and sysFreeString. For other OS specifics, I rely on FreeBasic/GNU to mediate.

Charles

Charles Pegge
03-07-2009, 08:38
Hi Frank,

I will start a new topic for thinBasic/Oxygen modules with some more example functions.

Charles

John Spikowski
03-07-2009, 09:02
Charles,

The DYC, CIO, and NT ScriptBasic extension modules are Windows specific. Most of the others are cross platform wrappers for other open source projects. (MySQL, PostgreSQL, unixODBC, Berkeley DB, cURL, Gtk, ...) The T (tools) extension module has functions that Peter felt didn't belong in the core (single source) interpreter. (array to string, MD5, file to string, ...)

The DYC (Windows generic DLL interface) is a fast way to test your POC with ScriptBasic. I'm really excited about what this could do to get more compiler only people to try a simple to use interpreter with a Turbo Thruster when needed. :D

http://files.allbasic.info/thinBASIC/turbo_thruster.jpg

John

jcfuller
03-07-2009, 12:10
Charles,
Is there some obstacle where a generic O2(dll/so) is not feasible? Personally I would prefer to see a generic solution rather than you using your limited time on another language specific extension?

James

John Spikowski
03-07-2009, 12:35
James,

Oxygen is made for interpreters. Why would a compiled program call a JIT compiler?

ScriptBasic will allow Oxygen to run on both Windows and Linux using a common code base.

Let Charles have a peek at ScriptBasic and see how much of an effort it will be before you run the project off the road.


John

ErosOlmi
03-07-2009, 17:11
:whacky34:

zak
03-07-2009, 17:30
Hi all
since charles said
"""""""""" Time is the major limitation """"""""""""
and if i have to vote: i vote for the most General DLL (in the future), which are usable also in the VB6
and a special DLL with ultra hight specifications for thinbasic
regards

Charles Pegge
03-07-2009, 18:00
I like the self assembling robot!

And don't worry - It is no great burden to rewrite the top end for tight integration for a specific interpreter or other application. In fact generic Oxygen can be compiled by omitting the thinBasic_Oxygen.bas. No changes to the source code are needed.

But right now I have an unexpected problem with thinBasic modules creation, which I think was causing errors for Frank. thinBasic_LoadSymbol works once, but not on subsequent calls - I suspect Library instancing/thread problems. ThinCore late binds to the Oxygen DLL which in turn late binds to Oxygen and then thinCore. I wonder if this is too much?

Charles

Michael Hartlef
03-07-2009, 18:41
thinBasic_LoadSymbol is called once and automatically when thinBasic reaches a USE command. Do you mean that you have several USE calls with the same module name in your thinBasic script?

Charles Pegge
03-07-2009, 20:38
Hi Michael,

I think you are referring to LoadLocalSymbols, within which there are several thinBasic_LoadSymbol - one for each module function.

So far, I have verified that both early (static) and late (dynamic) binding to thinCore works perfectly in FreeBasic.
but although Oxygen late binds to the Windows API and Opengl dlls with no problems, and appears to hitch onto thnCore okay, thinCore appears not to recognize all the symbols delivered by thinBasic_LoadSymbol unless I put messageboxes inbetween each LoadSymbol call. I have not found a reasonable explanation for this yet.

At least trying to describe the problem helps. Thanks!

Charles

zlatkoAB
03-07-2009, 20:51
Hi...
And if i have to vote:
I also vote for the General DLL which are usable in other
languages.
I make few tests with CBasic and EBasic and looks
promising.

Great work Charles :D

Michael Hartlef
04-07-2009, 00:00
Yes you are right .LoadLocalSymbols

zak
04-07-2009, 16:55
Hi Charles
in the vb6 code:


Private Sub Command1_Click()
Dim src As String
Dim v As Long

src = " dim a as quad : dim i as long: for i=1 to 100000: a=a+i : next i: Print str a: mov eax,a :terminate "

o2_basic src
v = o2_exec
MsgBox v

End Sub

i get for the msgbox from O2 the correct answer 5000050000
but in the msgbox from vb6 the answer 705082704
but the two msgboxes are the same if the i=1 to 10000 or 1000 ...
why is this?
i have tried to call your dll from perl, i have difficulties in perl calling api, so i have posted a question with a reference to your o2h page , and i am waiting the answers. at this thread:
http://www.perlmonks.com/?node_id=777231

a reference for the perl api here:
http://search.cpan.org/~acalpini/Win32-API-0.41/API.pm
regards

Michael Hartlef
04-07-2009, 18:22
Zak, QUAD and LONG have usually a different bit size. Or is a LONG in VB the same size as QUAD in O2?

zak
04-07-2009, 18:45
Hi Mike
you are right the Long in vb6 is a 4-Bytes integer, while double is a 8-byte floating point number , there is no quad in vb6.
regards

Michael Hartlef
04-07-2009, 19:52
So that is why you get a different result. The 4byte long simply can't hold a value of 5 000 050 000.

Charles Pegge
04-07-2009, 20:40
Hi Zak,

Re Quads:

with mov eax,a only the lower 32 bits are returned. Without being able to link to VB6 variables, its going to be fairly restrictive.

But for those languages that support late DLL binding, we could use Oxygen to generate DLLs (containing exported functions and subs) on the fly then use them in the normal way.

Charles.