Modify

Opened 2 months ago

#3695 new Feature Request

Func _SQLite_Display2DResult($aResult, $iCellWidth = 0, $bReturn = False, $sDelim_Col = "", $sDelim_Row = @CRLF)

Reported by: argumentum Owned by:
Milestone: 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 (0)

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.

Add Comment

Modify Ticket

Action
as new The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.