Opened 14 years ago
Last modified 12 years ago
#1861 closed Bug
_ArrayDisplay: Bug when data contains separator and $sHeader is used — at Version 3
Reported by: | Thomas Rupp <thomas.rupp@…> | Owned by: | Gary |
---|---|---|---|
Milestone: | 3.3.9.5 | Component: | Standard UDFs |
Version: | 3.3.6.1 | Severity: | None |
Keywords: | Cc: |
Description (last modified by trancexx)
If the table to display contains the default GUIDataSeparatorChar ("|") and you use $sHeader the resulting display is wrong.
Example:
#include <array.au3> Global $aTestArray1[1] = ["Test|Row 1"] _ArrayDisplay($aTestArray1, "Test Array 1", -1, 0, "", "|", "Rows|Column0")
should result in:
Rows Column0
[0] Test|Row 1
but you get:
Rows|Column0
[0]
[0]
Suggested solution:
Replace (starting with line 362):
; Set header up If $sHeader = "" Then $sHeader = "Row " ; blanks added to adjust column size for big number of rows For $i = 0 To $iSubMax $sHeader &= $sSeparator & "Col " & $i Next EndIf
with:
; Set header up If $sHeader = "" Then $sHeader = "Row " ; blanks added to adjust column size for big number of rows For $i = 0 To $iSubMax $sHeader &= $sSeparator & "Col " & $i Next ElseIf $sDataSeparatorChar <> $sSeparator Then $sHeader = StringReplace($sHeader, $sDataSeparatorChar, $sSeparator) EndIf
Change History (3)
comment:1 Changed 14 years ago by mvg
comment:2 Changed 14 years ago by mvg
First problem I see here is that at [1] the default Chr(124) delimiter is activly skipped as part of the array data checkup part, or if will never fail if the delimiter character is used/present in the array data.
A second (general) problem ... is that if the function allouws to set the used delimiter it should either be used onconditionally. And not be addjusted to a free delimiter character.
The point here in my mind is that if you adjust the used delimiter ... there seems to be no use for it as a supported parameter. (as the delimiter only purpuse is to make the array display not to get mangled up by a inappropriate used delimiter-char.)
... that makes any sense ?
Func _ArrayDisplay(Const ByRef $avArray, $sTitle = "Array: ListView Display", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "", $sReplace = "|", $sHeader = "") ;; <snip> ; Separator handling ;~ If $sSeparator = "" Then $sSeparator = Chr(1) If $sSeparator = "" Then $sSeparator = Chr(124) ; Check the separator to make sure it's not used literally in the array If _ArraySearch($avArray, $sSeparator, 0, 0, 0, 1) <> -1 Then For $x = 1 To 255 [1] If $x >= 32 And $x <= 127 Then ContinueLoop Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) If $sFind = -1 Then $sSeparator = Chr($x) ExitLoop EndIf Next EndIf ;; <snip>
comment:3 Changed 13 years ago by trancexx
- Description modified (diff)
Please (redo and) use correct and runnable example code.
| Global $aTestArray1[1] = Test|Row 1?