Yes!
thinBasic_LoadSymbol accepts dword-aligned pseudo-bstrings.
I have posted the updates on Github.
This is my latest revision of thinBasic_Oxygen.dll. It is not quite so low-level, and demonstrates how to late-bind to a DLL. In this case, Oxygen.dll with its location given by spath.
'COMPILING WITH OXYGEN
'11:08 13/12/2013
'12:01 29/06/2018
'Charles E V Pegge
'
$ dll
$ filename "thinBasic_Oxygen.dll"
uses RTL32
% late_binding
% TB_TRUE 1
% TB_FALSE 0
' Return Types from functions/Subs
'=================================
% thinBasic_ReturnNone 0 'Used in thinBasic_LoadSymbol to define a sub
% thinBasic_ReturnNumber 20 'Used in thinBasic_LoadSymbol to define a function returning a EXT number
% thinBasic_ReturnString 30 'Used in thinBasic_LoadSymbol to define a function returning a string
% thinBasic_ReturnCodeByte 1
% thinBasic_ReturnCodeInteger 2
% thinBasic_ReturnCodeWord 3
% thinBasic_ReturnCodeDWord 4
% thinBasic_ReturnCodeLong 5
% thinBasic_ReturnCodeQuad 6
% thinBasic_ReturnCodeSingle 7
% thinBasic_ReturnCodeDouble 8
% thinBasic_ReturnCodeCurrency 9
% thinBasic_ReturnCodeExt 10
% thinBasic_ReturnCodeString 30
% thinBasic_ForceOverWrite 1 'Used in thinBasic_LoadSymbol to force symbol over writing
extern stdcall lib "thinCore.dll"
=================================
! thinBasic_ParseLong (sys*sResult)
! thinBasic_ParseString (string*sResult) as double
! thinBasic_CheckOpenParens_Optional () as sys
! thinBasic_CheckCloseParens_Mandatory () as sys
! thinBasic_GetRunTimeInfo (string InfoName) as string
! thinBasic_VariableGetInfoEX (string SearchKey, sys *pMainType,*pSubType,*pIsArray,*pDataPtr,*pnElements,WhichLevel) as sys
! thinBasic_LoadSymbol (string SymbolName,sys ReturnCode,FunctionOrSubPointer,ForceOverWrite) as sys
end extern
sys oxygen
sys ParensPresent
string src,cod
double dv
'
extern stdcall
==============
'
'DECLARATIONS FOR LATE BINDING TO OXYGEN.DLL
'
!* o2_abst (string s) as string
!* o2_asmo (string s) as sys
!* o2_basic (string s) as sys
!* o2_exec (sys p=0) as sys
!* o2_buf (sys n) as sys
!* o2_errno () as sys
!* o2_error () as string
!* o2_len () as sys
!* o2_lib () as sys
!* o2_link (string s) as sys
!* o2_mode (sys m)
!* o2_pathcall (sys m)
!* o2_prep (string s) as string
!* o2_varcall (sys m)
!* o2_version () as string
!* o2_view (string s) as string
function GetvarPtr(char*z) as sys, callback
===========================================
'
string VarName=z
sys MainType, SubType, IsArray, DataPtr, nElements, WhichLevel
thinBasic_VariableGetInfoEX Varname, MainType, SubType, IsArray,
DataPtr, nElements, WhichLevel
return DataPtr
end function
'Function GetRuntimeInfo(char*z) as sys
'======================================
'
'static string n=z
''n="APP_PATH" ' also "SCRIPT_PATH" "HWND"
'n=thinBasic_GetRunTimeInfo(n)
'return strptr n
'End Function
Function inclpath(char*z) as char*
==================================
'
static string wd
static string pth="APP_PATH"
wd=lcase z
if left(wd,17)="%app_includepath%" then
wd=thinBasic_GetRuntimeInfo(pth)+"inc"+mid(wd,18)
end if
return wd
end Function
#define HOSTED
Function tbo2_len() as sys
==========================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
Function = call o2_len
End Function
Function tbo2_buf() as sys
==========================
'
sys p
ParensPresent = thinBasic_CheckOpenParens_Optional()
thinBasic_ParseLong(p)
function=call o2_buf p
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
End Function
Function tbo2_exec() as sys
===========================
'
sys p
ParensPresent = thinBasic_CheckOpenParens_Optional()
If ParensPresent = TB_TRUE Then
dv=thinBasic_ParseString(cod)
p=strptr cod
thinBasic_CheckCloseParens_Mandatory()
end if
function=o2_exec p
End Function
Function tbO2_Link() as sys
===========================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
dv=thinBasic_ParseString(src)
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_link src
End Function
sub tbo2_Asmo()
===============
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
dv=thinBasic_ParseString(src)
call o2_asmo src
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
End Sub
sub tbO2_BASIC()
================
'
tbo2_asmo()
end sub
Function tbo2_View() as sys
===========================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
dv=thinBasic_ParseString(src)
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_view src
End Function
Function tbo2_Prep() as sys
===========================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
dv=thinBasic_ParseString(src)
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_prep src
End Function
Function tbo2_Abst() as sys
===========================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
dv=thinBasic_ParseString(src)
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_abst src
End Function
Function tbo2_Error() as sys
============================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_error
End Function
Function tbo2_Errno() as sys
'===========================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_errno
End Function
Function tbo2_Version() as sys
==============================
'
ParensPresent = thinBasic_CheckOpenParens_Optional()
If ParensPresent = TB_TRUE Then thinBasic_CheckCloseParens_Mandatory()
return call o2_version
End Function
Function finish() external
==========================
if oxygen then FreeLibrary oxygen
terminate
End Function
Function LoadLocalSymbols cdecl (string sPath) as sys, export
=============================================================
/*
This function is automatically called by thinCore whenever this DLL module is loaded.
This function MUST (repeat MUST) be present in every external DLL module you want to use
with thinBasic
Use this function to initialize every you need and for loading the
new symbol (read Keyword) you have created.
*/
'LATE BINDING TO OXYGEN.DLL
'
oxygen=loadlibrary spath+"oxygen.dll"
'
if oxygen=0
print "Oxygen.dll not here: " spath
exit function
end if
'
def lp
@%1=GetProcAddress oxygen,"%1"
end def
'
lp o2_mode
lp o2_len
lp o2_buf
lp o2_exec
lp o2_lib
lp o2_link
lp o2_asmo
lp o2_basic
lp o2_abst
lp o2_prep
lp o2_view
lp o2_error
lp o2_errno
lp o2_varcall
lp o2_pathcall
lp o2_version
'
o2_mode(9) 'bstrings UTF8
o2_varcall @GetVarPtr 'var callback pointer. proc for passing host variable name and returning variable pointer
o2_pathcall @InclPath 'path callback to get path
'
string mdl_path=spath
thinBasic_LoadSymbol ("O2_Abst", thinBasic_ReturnString, @tbo2_Abst, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Asmo", thinBasic_ReturnNone, @tbo2_Asmo, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Basic", thinBasic_ReturnNone, @tbo2_Basic, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Buf", thinBasic_ReturnCodeLong, @tbO2_Buf, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Errno", thinBasic_ReturnCodeLong, @tbo2_Errno, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Error", thinBasic_ReturnString, @tbo2_Error, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Eval", thinBasic_ReturnString, @tbo2_Link, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Exec", thinBasic_ReturnCodeLong, @tbO2_Exec, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Len", thinBasic_ReturnCodeLong, @tbO2_Len, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Link", thinBasic_ReturnString, @tbo2_Link, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Prep", thinBasic_ReturnString, @tbo2_Prep, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_View", thinBasic_ReturnString, @tbo2_View, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("Oxygen_Eval", thinBasic_ReturnString, @tbo2_Link, thinBasic_ForceOverWrite)
thinBasic_LoadSymbol ("O2_Version", thinBasic_ReturnString, @tbo2_Version, thinBasic_ForceOverWrite)
End Function
Function UnLoadLocalSymbols cdecl (string sPath) as sys, export
===============================================================
End Function
end extern