Passing more than 32 parameters to a PowerBasic DLL

User Rob Hoveling has discovered that PowerBasic(PB) does not allow more than 32 parameters to be passed to a PB DLL. However, he has created a clever work around to the problem. You simply tell PB that it is being passed a user defined type (UDT) by-value, and that type contains a pointer for each parameter NeuroShell is passing. Here is Rob’s sample code for passing parameters when making a NeuroShell by-array call to a dll:

TYPE NSTRecord
PointerOpen AS DOUBLE PTR ‘Call ByRef Double / Time Series in NST
PointerHigh AS DOUBLE PTR ‘Call ByRef Double / Time Series in NST
PointerLow AS DOUBLE PTR ‘Call ByRef Double / Time Series in NST
PointerClose AS DOUBLE PTR ‘Call ByRef Double / Time Series in NST
PointerVolume AS LONG PTR ‘Call ByRef Long / Time Series in NST
PointerOpenInterest AS LONG PTR ‘Call ByRef Long / Time Series in NST
PointerNextOpen AS DOUBLE PTR ‘Call ByRef Double / Time Series in NST
PointerSymbol AS LONG PTR ‘Call ByRef Long / Time Series in NST
PointerDate AS DOUBLE PTR
PointerPar1 AS DOUBLE PTR ‘The number of variables can be expanded
PointerPar2 AS DOUBLE PTR ‘up to the limits of NST
PointerPar3 AS DOUBLE PTR’ The Pointer and Value types should mach with NST
PointerPar4 AS DOUBLE PTR
PointerPar5 AS DOUBLE PTR
ValueBarcounter AS LONG ‘Call ByVal Long # Bars
PointerOutArray AS DOUBLE PTR
END TYPE

SUB MyFunc ALIAS “MyFunc”(BYVAL NST AS NSTRecord) EXPORT

‘Now you can acces the value for each bar by using the prefix “NST.@” for each item passed ‘ByRef and by using the prefix “NST.” for each item passed ByVal, as this examples shows:

DIM i AS LONG

FOR i = 0 TO NST.ValueBarcounter-1
‘Puts back the difference between high an low
NST.@PointerOutArray = NST.@PointerHigh – NST.@PointerLow
NEXT i

END SUB

Was this article helpful?

Related Articles