61
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 14, 2024, 06:21:32 PM »I figured out what the issue was with OxygenBasic calling functions with a 64 bit pointer. I replaced cdecl with ms64 and the program compiled and ran. There still is an issue passing a double (real) to O2.
test.sb
I tried all the other O2 floating point types besides double and nothing works.
Code: Text
- ' O2 SB Embed
- % filename "o2sb64.exe"
- includepath "$/inc/"
- uses rtl64
- % libScriba = "libScriba.dll"
- indexbase 0
- type SbData
- typ as dword
- siz as dword
- union {
- dbl as double
- lng as sys
- str as char*
- gen as sys
- }
- end type
- #define SBT_UNDEF 0
- #define SBT_DOUBLE 1
- #define SBT_LONG 2
- #define SBT_STRING 3
- #define SBT_ZCHAR 4
- sys pProgram, iError, cArgs
- sys f1, f2, v
- sys n, m
- sys qdat
- SbData ReturnData, ArgData[3]
- sbData pdat
- sys sb=LoadLibrary libScriba
- extern ms64
- bind sb
- {
- scriba_new
- scriba_SetStdin()
- scriba_SetStdout()
- scriba_SetEmbedPointer()
- scriba_LoadConfiguration
- scriba_destroy
- scriba_DestroySbData
- scriba_SetFileName
- scriba_LoadSourceProgram
- scriba_LoadProgramString
- scriba_Run
- scriba_GetVariable
- scriba_SetVariable
- scriba_LookupVariableByName
- scriba_LookupFunctionByName
- scriba_Call
- scriba_CallArg
- scriba_NewSbArgs
- scriba_CallArgEx
- scriba_DestroySbArgs
- scriba_DestroySbData
- scriba_NewSbString
- }
- end extern
- function newmem ms64 (sys le) as sys, export
- return getmemory le
- end function
- function freemem ms64 (sys p) export
- freememory p
- end function
- pProgram = scriba_new(@newmem, @freemem)
- scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
- scriba_SetFileName(pProgram, "test.sb")
- scriba_LoadSourceProgram(pProgram)
- scriba_Run(pProgram,"")
- ' Get Global Var
- sbdata *p
- v = scriba_LookupVariableByName(pProgram, "main::a")
- scriba_GetVariable(pProgram, v, @@p)
- print "A: " + str(p.lng)
- ' Create SB Variant Array
- sbData *arg
- @arg = scriba_NewSbArgs(pProgram,"i r s", 1, .2, "three")
- print str(arg[0].lng) + " | " + str(arg[1].dbl) + " | " + arg[2].str
- scriba_DestroySbArgs(pProgram, arg, 3)
- scriba_DestroySbData(pProgram, arg)
- scriba_destroy(pProgram)
test.sb
Code: ScriptBasic
- a = 99
Code: Text
- type SbData
- typ as dword
- siz as dword
- union {
- dbl as double
- lng as sys
- str as char*
- gen as sys
- }
- end type
I tried all the other O2 floating point types besides double and nothing works.