Modify ↓
#3695 closed Feature Request (Completed)
Func _SQLite_Display2DResult($aResult, $iCellWidth = 0, $bReturn = False, $sDelim_Col = "", $sDelim_Row = @CRLF)
Reported by: | argumentum | Owned by: | Jpm |
---|---|---|---|
Milestone: | 3.3.15.4 | Component: | Standard UDFs |
Version: | Severity: | None | |
Keywords: | _SQLite_Display2DResult | Cc: |
Description
; #FUNCTION# ==================================================================================================================== ; Author ........: piccaso (Fida Florian) ; Modified.......: jchd, argumentum (02.03.19 - added flexibility) ; =============================================================================================================================== Func _SQLite_Display2DResult($aResult, $iCellWidth = 0, $bReturn = False, $sDelim_Col = "", $sDelim_Row = @CRLF) If Not IsArray($aResult) Or UBound($aResult, $UBOUND_DIMENSIONS) <> 2 Or $iCellWidth < 0 Then Return SetError(1, 0, "") Local $aiCellWidth If $iCellWidth = 0 Or $iCellWidth = Default Then Local $iCellWidthMax Dim $aiCellWidth[UBound($aResult, $UBOUND_COLUMNS)] For $iRow = 0 To UBound($aResult, $UBOUND_ROWS) - 1 For $iCol = 0 To UBound($aResult, $UBOUND_COLUMNS) - 1 $iCellWidthMax = StringLen($aResult[$iRow][$iCol]) If $iCellWidthMax > $aiCellWidth[$iCol] Then $aiCellWidth[$iCol] = $iCellWidthMax EndIf Next Next EndIf Local $sOut = "", $iCellWidthUsed For $iRow = 0 To UBound($aResult, $UBOUND_ROWS) - 1 For $iCol = 0 To UBound($aResult, $UBOUND_COLUMNS) - 1 If $iCellWidth = 0 Then $iCellWidthUsed = $aiCellWidth[$iCol] Else $iCellWidthUsed = $iCellWidth EndIf $sOut &= StringFormat(" %-" & $iCellWidthUsed & "." & $iCellWidthUsed & "s ", $aResult[$iRow][$iCol]) & $sDelim_Col Next $sOut &= $sDelim_Row If Not $bReturn Then __SQLite_Print($sOut) $sOut = "" EndIf Next If $bReturn Then Return $sOut EndFunc ;==>_SQLite_Display2DResult
This version has the possibility to declare Column and Row delimitation.
Test code is at https://www.autoitscript.com/forum/topic/197277-_arrayfromstring/?do=findComment&comment=1417567
This change is not code braking.
Attachments (0)
Change History (3)
comment:1 Changed 5 years ago by Jpm
- Owner set to Jpm
- Status changed from new to assigned
comment:2 Changed 5 years ago by Jpm
- Milestone set to 3.3.15.4
- Resolution set to Completed
- Status changed from assigned to closed
comment:3 Changed 4 years ago by argumentum
..there was a missing Default(s), so I added them all. ..and other tweaks.
; #FUNCTION# ==================================================================================================================== ; Author ........: piccaso (Fida Florian) ; Modified.......: jchd, argumentum ; =============================================================================================================================== Func _SQLite_Display2DResult($aResult, $iCellWidth = 0, $bReturn = False, $sDelim_Col = "", $sDelim_Row = @CRLF) If Not IsArray($aResult) Or UBound($aResult, $UBOUND_DIMENSIONS) <> 2 Or $iCellWidth < 0 Then Return SetError(1, 0, "") Local $aiCellWidth If $iCellWidth = Default Then $iCellWidth = 0 If $sDelim_Col = Default Then $sDelim_Col = "" If $sDelim_Row = Default Then $sDelim_Row = @CRLF If $iCellWidth = 0 Or $iCellWidth = Default Then Local $iCellWidthMax Dim $aiCellWidth[UBound($aResult, $UBOUND_COLUMNS)] For $iRow = 0 To UBound($aResult, $UBOUND_ROWS) - 1 For $iCol = 0 To UBound($aResult, $UBOUND_COLUMNS) - 1 $iCellWidthMax = StringLen($aResult[$iRow][$iCol]) If $iCellWidthMax > $aiCellWidth[$iCol] Then $aiCellWidth[$iCol] = $iCellWidthMax EndIf Next Next EndIf Local $sOut = "", $iCellWidthUsed Local $iUBound_ROWS = UBound($aResult, $UBOUND_ROWS) - 1 Local $iUBound_COLS = UBound($aResult, $UBOUND_COLUMNS) - 1 For $iRow = 0 To $iUBound_ROWS For $iCol = 0 To $iUBound_COLS If $iCellWidth = 0 Then $iCellWidthUsed = $aiCellWidth[$iCol] Else $iCellWidthUsed = $iCellWidth EndIf $sOut &= StringFormat(" %-" & $iCellWidthUsed & "." & $iCellWidthUsed & "s ", $aResult[$iRow][$iCol]) If $iCol <> $iUBound_COLS Then $sOut &= $sDelim_Col Next $sOut &= $sDelim_Row If Not $bReturn Then __SQLite_Print($sOut) $sOut = "" EndIf Next If $bReturn Then If $sDelim_Col <> "" Then $sOut = StringTrimRight($sOut, StringLen($sDelim_Row)) Return $sOut EndIf EndFunc ;==>_SQLite_Display2DResult
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.
Added by revision [12326] in version: 3.3.15.4