A search of this forum for OxygenBasic did return some hits, but nothing that would help me.
This thread from 2012 says it has been done;
Ref: viewtopic.php?p=389922#p389922
The OxygenBasic Github site;
https://github.com/Charles-Pegge/OxygenBasic
Oxygen64.dll is a 64-bit .dll;
Code: Select all
E:\...\Oxygen>file oxygen64.dll
oxygen64.dll: PE32+ executable (DLL) (GUI) x86-64, for MS Windows
Code: Select all
Volume in drive E is New Volume Serial number is 2c1e:6e61
Directory of E:\Documents\PureBasic\Oxygen\*
2023-11-14 9:50 <DIR> .
2023-11-14 9:50 <DIR> ..
2023-11-13 22:39 141,312 oxygen64.dll
2023-11-14 9:55 13,824 test.exe
2023-11-14 9:55 740 test.pb
155,876 bytes in 3 files and 2 dirs 163,840 bytes allocated
Code: Select all
theString.s
If OpenLibrary(0, "oxygen64.dll")
thestring = "result=10+20"
oAddr = CallCFunction(0, "o2_basic", @"thestring")
; and/or instead of thestring, an .o2bas file
; Use o2_exec to execute thestring, and return the result
oExec = CallCFunction(0, "o2_exec", oAddr)
; Get the result, which should be 30, and store it in oString
; Not sure how this would be accomplished.
If OpenConsole()
; PrintN(oString)
PrintN("Result to be printed.")
EndIf
Else
PrintN("Error opening oxygen.dll")
EndIf
I then step through this code, and the WatchList displays both oAddr and oExec returning 0.
Not sure if, in my test code, this is the proper way to call the functions from the dll.
I have also managed to create a Oxygen64.lib file;
I have created oxygen64.def from the oxygen64.dll;
Code: Select all
E:\...\Oxygen>dumpbin /exports oxygen64.dll > oxygen64.def
Microsoft (R) COFF/PE Dumper Version 14.37.32825.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file oxygen64.dll
File Type: DLL
Section contains the following exports for oxygen64.dll
00000000 characteristics
0 time date stamp
0.00 version
1 ordinal base
17 number of functions
17 number of names
ordinal hint RVA name
1 0 000A57F0 o2_abst
2 1 000A55B0 o2_basic
3 2 000A38D0 o2_buf
4 3 000A3E30 o2_compile
5 4 000A5880 o2_errno
6 5 000A58E0 o2_error
7 6 000A3C50 o2_exec
8 7 000A3860 o2_len
9 8 000A3A10 o2_lib
10 9 000A3D30 o2_link
11 A 000A3800 o2_mode
12 B 000A37A0 o2_pathcall
13 C 000A5770 o2_prep
14 D 000A4CD0 o2_stats
15 E 000A3740 o2_varcall
16 F 000A5980 o2_version
17 10 000A56F0 o2_view
Summary
303000 UPX0
22000 UPX1
1000 UPX2
Code: Select all
EXPORTS
o2_abst
o2_basic
o2_buf
o2_compile
o2_errno
o2_error
o2_exec
o2_len
o2_lib
o2_link
o2_mode
o2_pathcall
o2_prep
o2_stats
o2_varcall
o2_version
o2_view
Code: Select all
E:\...\Oxygen>lib /def:oxygen64.def /out:oxygen64.lib /machine:x64
Microsoft (R) Library Manager Version 14.37.32825.0
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library oxygen64.lib and object oxygen64.exp
Code: Select all
E:\...\Oxygen>dir
Volume in drive E is New Volume Serial number is 2c1e:6e61
Directory of E:\Documents\PureBasic\Oxygen\*
2023-11-14 10:24 <DIR> .
2023-11-14 10:24 <DIR> ..
2023-11-14 10:24 178 oxygen64.def
2023-11-14 10:24 169 oxygen64.def.bak
2023-11-13 22:39 141,312 oxygen64.dll
2023-11-14 10:24 2,275 oxygen64.exp
2023-11-14 10:24 4,362 oxygen64.lib
2023-11-14 9:55 13,824 test.exe
2023-11-14 10:08 783 test.pb
162,903 bytes in 7 files and 2 dirs 184,320 bytes allocated
Code: Select all
dumpbin /exports oxygen64.lib
Microsoft (R) COFF/PE Dumper Version 14.37.32825.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file oxygen64.lib
File Type: LIBRARY
Exports
ordinal name
o2_abst
o2_basic
o2_buf
o2_compile
o2_errno
o2_error
o2_exec
o2_len
o2_lib
o2_link
o2_mode
o2_pathcall
o2_prep
o2_stats
o2_varcall
o2_version
o2_view
Summary
C6 .debug$S
14 .idata$2
14 .idata$3
8 .idata$4
8 .idata$5
E .idata$6
Code: Select all
ImportC "Oxygen64.lib"
o2_basic
o2_exec
EndImport
Ref: http://forum.it-berater.org/index.php?topic=4638.0
From his PowerBasic code, it shows that o2_basic accepts a byval string, and returns a string.
Also, o2_exec accepts an optional byval long, and returns a long.
I note that this is 32-bit, since PowerBasic is only 32-bit.
Not sure how to duplicate this in PureBasic.
I was also wondering if I should use Import instead of ImportC, but the help says;
Constructive assistance would be appreciated on how to get this working,On x64, there is only one calling convention, so ImportC will behave the sames as Import.
and how to return results from the call back to PureBasic.
Joe