summaryrefslogtreecommitdiff
path: root/wizards/source
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2016-11-30 16:50:13 +0100
committerJean-Pierre Ledure <jp@ledure.be>2017-01-12 11:40:49 +0100
commit62e508c2a78ac4a9cabe0d9bb878f0f7bd487f88 (patch)
tree4175eaa9412390e8eb9441452f9092431cbf0d43 /wizards/source
parent53d261f2ff92d3da5655f729b433a36b4ea2733c (diff)
Access2Base - More accurate CStr function
Includes arrays, distinguishes integers and real numbers Side effects in DebugPrint solved Change-Id: Id84203cea1a93dcbc164f8661fcf2f57778b0df8
Diffstat (limited to 'wizards/source')
-rw-r--r--wizards/source/access2base/Compatible.xba8
-rw-r--r--wizards/source/access2base/Utils.xba29
2 files changed, 25 insertions, 12 deletions
diff --git a/wizards/source/access2base/Compatible.xba b/wizards/source/access2base/Compatible.xba
index 92012b56a420..77e99bcdc97c 100644
--- a/wizards/source/access2base/Compatible.xba
+++ b/wizards/source/access2base/Compatible.xba
@@ -23,18 +23,14 @@ Const cstTab = 5
If UBound(pvArgs) &gt;= 0 Then
For i = 0 To UBound(pvArgs)
-&apos; If IsError(pvArgs(i)) Then &apos; IsError gives &quot;Object variable not set&quot; in LO 4,0 ?!?
-&apos; pvArgs(i) = &quot;[ERROR]&quot;
-&apos; Else
- If Not Utils._CheckArgument(pvArgs(i), i + 1, vVarTypes(), , False) Then pvArgs(i) = &quot;[TYPE?]&quot;
-&apos; End If
+ If Not Utils._CheckArgument(pvArgs(i), i + 1, vVarTypes(), , False) Then pvArgs(i) = &quot;[TYPE?]&quot;
Next i
End If
Dim sOutput As String, sArg As String
sOutput = &quot;&quot;
For i = 0 To UBound(pvArgs)
- sArg = Utils._CStr(pvArgs(i), _A2B_.DebugPrintShort)
+ sArg = Replace(Utils._CStr(pvArgs(i), _A2B_.DebugPrintShort), &quot;\;&quot;, &quot;;&quot;)
&apos; Add argument to output
If i = 0 Then
sOutput = sArg
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba
index d84259696ce2..8514d95feae5 100644
--- a/wizards/source/access2base/Utils.xba
+++ b/wizards/source/access2base/Utils.xba
@@ -132,15 +132,24 @@ Public Function _CStr(ByVal pvArg As Variant, ByVal Optional pbShort As Boolean)
Dim sArg As String, sObject As String, oArg As Object, sLength As String, i As Long, iMax As Long
Const cstLength = 50
Const cstByteLength = 25
+
+ If IsMissing(pbShort) Then pbShort = True
If IsArray(pvArg) Then
- If VarType(pvArg) = vbByte Or VarType(pvArg) - 8192 = vbByte Then
- sArg = &quot;&quot;
+ sArg = &quot;&quot;
+ If VarType(pvArg) = vbByte Or VarType(pvArg) = vbArray + vbByte Then
If pbShort And UBound(pvArg) &gt; cstByteLength Then iMax = cstByteLength Else iMax = UBound(pvArg)
For i = 0 To iMax
sArg = sArg &amp; Right(&quot;00&quot; &amp; Hex(pvArg(i)), 2)
Next i
Else
- sArg = &quot;[ARRAY]&quot;
+ If pbShort Then
+ sArg = &quot;[ARRAY]&quot;
+ Else &apos; One-dimension arrays only
+ For i = LBound(pvArg) To UBound(pvArg)
+ sArg = sArg &amp; Utils._CStr(pvArg(i)) &amp; &quot;;&quot; &apos; Recursive call
+ Next i
+ If Len(sArg) &gt; 1 Then sArg = Left(sArg, Len(sArg) - 1)
+ End If
End If
Else
Select Case VarType(pvArg)
@@ -164,13 +173,21 @@ Const cstByteLength = 25
End If
End If
Case vbVariant : sArg = &quot;[VARIANT]&quot;
- Case vbString : sArg = pvArg
- Case vbBoolean : sArg = Iif(pvArg, &quot;TRUE&quot;, &quot;FALSE&quot;)
+ Case vbString
+ &apos; Replace CR + LF by \n
+ &apos; Replace semicolon by \; to allow semicolon separated rows
+ sArg = Replace(Replace(Replace(pvArg, Chr(13), &quot;&quot;), Chr(10), &quot;\n&quot;), &quot;;&quot;, &quot;\;&quot;)
+ Case vbBoolean : sArg = Iif(pvArg, &quot;[TRUE]&quot;, &quot;[FALSE]&quot;)
Case vbByte : sArg = Right(&quot;00&quot; &amp; Hex(pvArg), 2)
+ Case vbSingle, vbDouble, vbCurrency
+ sArg = Format(pvArg)
+ If InStr(UCase(sArg), &quot;E&quot;) = 0 Then sArg = Format(pvArg, &quot;##0.0##&quot;)
+ sArg = Replace(sArg, &quot;,&quot;, &quot;.&quot;)
+ Case vbDate : sArg = Year(pvArg) &amp; &quot;-&quot; &amp; Right(&quot;0&quot; &amp; Month(pvArg), 2) &amp; &quot;-&quot; &amp; Right(&quot;0&quot; &amp; Day(pvArg), 2) _
+ &amp; &quot; &quot; &amp; Right(&quot;0&quot; &amp; Hour(pvArg), 2) &amp; &quot;:&quot; &amp; Right(&quot;0&quot; &amp; Minute(pvArg), 2)
Case Else : sArg = CStr(pvArg)
End Select
End If
- If IsMissing(pbShort) Then pbShort = True
If pbShort And Len(sArg) &gt; cstLength Then
sLength = &quot;(&quot; &amp; Len(sArg) &amp; &quot;)&quot;
sArg = Left(sArg, cstLength - 5 - Len(slength)) &amp; &quot; ... &quot; &amp; sLength