Access2Base - Correct handling of empty arrays in UtilProperty
Avoid runtime error when storing an empty array (undocumented API) Change-Id: I3f8d31300dec365d7028dcd6bd9de2b24b2e0c4c
This commit is contained in:
@@ -217,8 +217,10 @@ Dim cstLF As String
|
|||||||
Case < vbArray ' Scalar
|
Case < vbArray ' Scalar
|
||||||
sResult = sResult & sName & " = " & Utils._CStr(vValue, False) & cstLF
|
sResult = sResult & sName & " = " & Utils._CStr(vValue, False) & cstLF
|
||||||
Case Else ' Vector or matrix
|
Case Else ' Vector or matrix
|
||||||
|
If uBound(vValue, 1) < 0 Then
|
||||||
|
sResult = sResult & sName & " = (0)" & cstLF
|
||||||
' 1-dimension but vector of vectors must also be considered
|
' 1-dimension but vector of vectors must also be considered
|
||||||
If VarType(vValue(0)) >= vbArray Then
|
ElseIf VarType(vValue(0)) >= vbArray Then
|
||||||
sResult = sResult & sName & " = (" & UBound(vValue) + 1 & "," & UBound(vValue(0)) + 1 & ")" & cstLF
|
sResult = sResult & sName & " = (" & UBound(vValue) + 1 & "," & UBound(vValue(0)) + 1 & ")" & cstLF
|
||||||
For j = 0 To UBound(vValue)
|
For j = 0 To UBound(vValue)
|
||||||
sResult = sResult & Utils._CStr(vValue(j), False) & cstLF
|
sResult = sResult & Utils._CStr(vValue(j), False) & cstLF
|
||||||
@@ -263,19 +265,24 @@ Const cstEqualArray = " = (", cstEqual = " = "
|
|||||||
If InStr(vString(i), cstEqualArray) = lPosition + Len(sName) Then ' Start array processing
|
If InStr(vString(i), cstEqualArray) = lPosition + Len(sName) Then ' Start array processing
|
||||||
lSearch = lPosition + Len(sName) + Len(cstEqualArray) - 1
|
lSearch = lPosition + Len(sName) + Len(cstEqualArray) - 1
|
||||||
sDim = Utils._RegexSearch(vString(i), "\([0-9]+\)", lSearch) ' e.g. (10)
|
sDim = Utils._RegexSearch(vString(i), "\([0-9]+\)", lSearch) ' e.g. (10)
|
||||||
If sDim <> "" Then
|
If sDim = "(0)" Then ' Empty array
|
||||||
|
iRows = -1
|
||||||
|
vValue = Array()
|
||||||
|
_SetPropertyValue(vResult, sName, vValue)
|
||||||
|
ElseIf sDim <> "" Then ' Vector with content
|
||||||
iCols = CInt(Mid(sDim, 2, Len(sDim) - 2))
|
iCols = CInt(Mid(sDim, 2, Len(sDim) - 2))
|
||||||
iRows = 0
|
iRows = 0
|
||||||
ReDim vValue(0 To iCols - 1)
|
ReDim vValue(0 To iCols - 1)
|
||||||
Else
|
iArray = 0
|
||||||
|
Else ' Matrix with content
|
||||||
lSearch = lPosition + Len(sName) + Len(cstEqualArray) - 1
|
lSearch = lPosition + Len(sName) + Len(cstEqualArray) - 1
|
||||||
sDim = Utils._RegexSearch(vString(i), "\([0-9]+,", lSearch) ' e.g. (10,
|
sDim = Utils._RegexSearch(vString(i), "\([0-9]+,", lSearch) ' e.g. (10,
|
||||||
iRows = CInt(Mid(sDim, 2, Len(sDim) - 2))
|
iRows = CInt(Mid(sDim, 2, Len(sDim) - 2))
|
||||||
sDim = Utils._RegexSearch(vString(i), ",[0-9]+\)", lSearch) ' e.g. ,20)
|
sDim = Utils._RegexSearch(vString(i), ",[0-9]+\)", lSearch) ' e.g. ,20)
|
||||||
iCols = CInt(Mid(sDim, 2, Len(sDim) - 2))
|
iCols = CInt(Mid(sDim, 2, Len(sDim) - 2))
|
||||||
ReDim vValue(0 To iRows - 1)
|
ReDim vValue(0 To iRows - 1)
|
||||||
End If
|
|
||||||
iArray = 0
|
iArray = 0
|
||||||
|
End If
|
||||||
ElseIf InStr(vString(i), cstEqual) = lPosition + Len(sName) Then
|
ElseIf InStr(vString(i), cstEqual) = lPosition + Len(sName) Then
|
||||||
vValue = Utils._CVar(Mid(vString(i), Len(sName) + Len(cstEqual) + 1))
|
vValue = Utils._CVar(Mid(vString(i), Len(sName) + Len(cstEqual) + 1))
|
||||||
_SetPropertyValue(vResult, sName, vValue)
|
_SetPropertyValue(vResult, sName, vValue)
|
||||||
|
Reference in New Issue
Block a user