is it possible in thinBasic to call a function with a dynamic count of function-parameters?
( all of the same, fixed-size type ).
Somewhat like MKL$( param1[, param2[, param3,...]] ) ?
or is the only way to pass a list (string) made up like MKL$, MKBYT$, MKDWD$, Memory_Get for UDt etc. and to place some layover there to read it out. But i don't want to create a string as first to pass the list of parameters to the function...
short example what i mean:
' i want to pass maybe 3, but maybe 33 or 333 longs, so have to do it alike
myFunc( MKL$(123, 234, 345) )
' or
myFunc( MKL$(123, 234, 345, 456, 567, 678,...) )
Function myFunc( Byval sLongs As String )
Local lLong(StrPtrlen(StrPtr(sLongs))/4) As Long At Strptr(sLongs)
' now the function has a list of long values available
' UBound(lLong) tells how many
End Function
and i want to do it without the MKL$, so to say- instant array alike
myFunc( 123, 234, 345 )
myFunc( 123, 234, 345, 456, 567, 678,... )
Function myFunc( ByVal lLong() As Long )
End Function
no doubt: this "ByVal lLong()" has to be the only - or last passed parameter.
None may follow.
Else it would need a syntax like on array-assignement using brackets here
(which i don't like)
myFunc( [123, 234, 345, 456, 567, 678,...] )' including [] brackets passed
In the other direction would be very interesting if one could automatically create a list from a function-result like this:
Function myFunc(Byval parameters As whatever) AS STRING
Local lResult(123) As Long
Function = Memory_Get( Varptr(lResult(1)), SizeOf(lResult) )
'EDIT: ' cool would be "Function = Array All lResult" instead
End Function
'------------------------------------------------
Dim lLong() AS LONG = myFunc(somedata)
' when assigning a STRING (on dimensioning) to something with
' empty parenthesis that is NOT a STRING it could instantly create fitting array...
Redim lLong() = myFunc( someOtherData ) '...
not far from returning dynamic arrays as function-result -
but the intention is indeed that i want to pass a list of same-type-parameters where nobody knows in advance how many.
Bookmarks