regarding new Keyword Into:
i like how it reads... and it's very clear what it does.
In a certain sense it's the reverse operation to variadic function-parameters...
Can we have Into useable for tB-script-functions too
Byref passed array-variable that can be dimensioned locally on the fly ?
Example
(tType be any Type of variable or udt)
'... "Into" could work like "ByRef" here,
' but signals an array-variable [with certain dimensions] will follow:
Function putStuff( Into X(~[dim1[, dim2[, dim3]]]~) As tType[, more parameters....]) As Long
' x be the array-varriable
' ~[dim1[, dim2[, dim3]]]~ not supposed to be written by the user as in line further above
' = dimensions bounds,
' "Into x() As tType" (empty parenthesis, no bounds) will serve,
' since Ubound(x, 2) = 0 if x has no 2nd dimension...
' if passed dim1[, dim2[, dim3]] on the call : (see below)
' fixed array size
' or 1-dimensional dynamic, contains already dim1 elements
' else
' x will be dynamic and contains 0 elements
' Endif
End Function
' equals:
Function putStuff( ByRef X() As tType[, more parameters....]) As Long
' no change necessary, only allow Alias ByRef As Into for this
End Function
' call :
Long l = putStuff( [Into|Preserve] myData[([dim1[, dim2[, dim3]]])[ As tType]][, more parameters...] )
' enable instant (re-)dimensioning and passing ByRef within function-call,
' If <"Into" present> Then
' ~~~ make a new, empty barrel for stuff to put into
' If variable_exists(myData) Then
' Redim myData([dim1[, dim2[, dim3]]])
' Else
' Dim myData([dim1[, dim2[, dim3]]]) [As tType]
' Endif
' ElseIf Variable_Exists(myData) Then
' ~~~ check for valid bounds
' If Not <"dim3" present> Then
' If Ubound(myData, 3) > 0 Then
' Long dim3 = Ubound(myData, 3) ~~~ assume we check for existance later
' EndIf
' If Not <"dim2" present> Then
' If Ubound(myData, 2) > 0 Then
' Long dim2 = Ubound(myData, 2)
' EndIf
' If Not <"dim1" present> Then
' If Ubound(myData, 1) > 0 Then
' Long dim1 = Ubound(myData, 1)
' Endif
' EndIf
' EndIf
' EndIf
' If <"Preserve" present> Then
' ~~~ obvious
' Redim Preserve myData([dim1[, dim2[, dim3]]])
' EndIf
' EndIf
' pass BYREF myData[(dim1[, dim2[, dim3]])][, more parameters...]> to function putStuff(...)
' finally real code reads as:
Local numBugs As Long = CollectBugs( Into myBuglist() As String )
' now i have a dimensioned - and hopefully empty - local array myBuglist
[post moved over here to keep other thread on topic]
Bookmarks