Leaderboard
Popular Content
Showing content with the highest reputation on 05/10/2025 in Posts
-
UDF "data-to-table.au3"
mLipok and 2 others reacted to SOLVE-SMART for a topic
data-to-table.au3 UDF Description This library (UDF) allows you to transform input data, like strings or arrays, to a nice readable table output with different border styles and aligned table cell content. Output your data to console, file or GUI. 👉 Please check out the upcoming features section. Acknowledgements The UDF is highly inspired by the great UDF "StringToTable.au3" by @ioa747 . Thank you! Forum thread link: https://www.autoitscript.com/forum/topic/212876-_stringtotable/ All credits for the original logic go to @ioa747 who made the UDF with ❤️ for a readable and elegant output. Input ==> Output From string ... ; The $sData string is separated (columns) by tabs. Local Const $sData = _ 'Language Popularity (%) Job Demand Typical Use' & @CRLF & _ 'JavaScript 62.3 Very High Web Development, Frontend/Backend' & @CRLF & _ 'C# 27.1 High Game Development, Windows Apps, Web Dev' & @CRLF & _ 'Go 13.8 Growing Cloud Services, System Programming' & @CRLF & _ 'PowerShell 13.5 Low to Moderate Task Automation, DevOps, System Admin' & @CRLF & _ 'AutoIt 0.5 Low Windows GUI Automation, Scripting' ... or array ... ; Default separator is @TAB. Local Const $aData[][5] = _ [ _ ['Language', 'Popularity (%)', 'Job Demand', 'Typical Use' ], _ ['JavaScript', '62.3', 'Very High', 'Web Development, Frontend/Backend' ], _ ['C#', '27.1', 'High', 'Game Development, Windows Apps, Web Dev' ], _ ['Go', '13.8', 'Growing', 'Cloud Services, System Programming' ], _ ['PowerShell', '13.5', 'Low to Moderate', 'Task Automation, DevOps, System Admin' ], _ ['AutoIt', '0.5', 'Low', 'Windows GUI Automation, Scripting' ] _ ] ... to ... ╔────────────┬────────────────┬─────────────────┬─────────────────────────────────────────╗ │ Language │ Popularity (%) │ Job Demand │ Typical Use │ ├────────────┼────────────────┼─────────────────┼─────────────────────────────────────────┤ │ JavaScript │ 62.3 │ Very High │ Web Development, Frontend/Backend │ │ C# │ 27.1 │ High │ Game Development, Windows Apps, Web Dev │ │ Go │ 13.8 │ Growing │ Cloud Services, System Programming │ │ PowerShell │ 13.5 │ Low to Moderate │ Task Automation, DevOps, System Admin │ │ AutoIt │ 0.5 │ Low │ Windows GUI Automation, Scripting │ ╚────────────┴────────────────┴─────────────────┴─────────────────────────────────────────╝ ... or other border styles (see below). Links of interest 👀 README ✨ the UDF (library) 🏃♂️ usage example 📑 CHANGELOG 🚀 Latest release Border styles Contribution, BUGs, issues, suggestions, wishes via GitHub issues / GitHub pull requests and/or here in the forum (also fine) Support give the project a ⭐ on GitHub follow me there come up with questions, suggestions, wishes 😀 Licenses Distributed under the MIT License. So don't worry and do whatever you want with it 😀 . -------------- Best regards Sven3 points -
_StringToTable
SOLVE-SMART and 2 others reacted to argumentum for a topic
Now this looks better: ╭──────────────────────┬──────────┬────────┬──────────┬───────────┬────────┬─────────┬────────╮ │ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range │ ├──────────────────────┼──────────┼────────┼──────────┼───────────┼────────┼─────────┼────────┤ │ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 │ │ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 │ │ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 │ │ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 │ │ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 │ ╰──────────────────────┴──────────┴────────┴──────────┴───────────┴────────┴─────────┴────────╯ with round corners ( mac / win11 style ) Joke aside, about making the char(s) an array and use the "set" array so the whole code don't have to change because someone came up with something "new" ? ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range █ █══════════════════════╪══════════╪════════╪══════════╪═══════════╪════════╪═════════╪════════█ █ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 █ █ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 █ █ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 █ █ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 █ █ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 █ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ┏━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━┯━━━━━━━━┓ ┃ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range ┃ ┠──────────────────────┼──────────┼────────┼──────────┼───────────┼────────┼─────────┼────────┨ ┃ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 ┃ ┃ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 ┃ ┃ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 ┃ ┃ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 ┃ ┃ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 ┃ ┗━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━┷━━━━━━━━┛ and what I would call "24 pin dot matrix"3 points -
_StringToTable() – Convert Text\array to a text formatted table The _StringToTable() function allows you to convert structured text (like tab-separated data), or array into a formatted, aligned table using Unicode box-drawing characters. Ideal for displaying readable output in console-based tools or logs. Example1: string to table Local $sData = _ "Company" & @TAB & "Contact" & @TAB & "Revenue" & @CRLF & _ "Alfreds Futterkiste" & @TAB & "Maria Anders" & @TAB & "1200" & @CRLF & _ "Centro Moctezuma" & @TAB & "Francisco Chang" & @TAB & "950" & @CRLF & _ "Island Trading" & @TAB & "Helen Bennett" & @TAB & "15800" ConsoleWrite(_StringToTable($sData, 3, @TAB, "L,C,R") & @CRLF) ┌──────────────────────┬───────────────────┬──────────┐ │ Company │ Contact │ Revenue │ ├──────────────────────┼───────────────────┼──────────┤ │ Alfreds Futterkiste │ Maria Anders │ 1200 │ │ Centro Moctezuma │ Francisco Chang │ 950 │ │ Island Trading │ Helen Bennett │ 15800 │ └──────────────────────┴───────────────────┴──────────┘ Example2: array to table ; Make example array Local $aArray[10][5] For $i = 0 To 9 For $j = 0 To 4 $aArray[$i][$j] = $i & "-" & $j Next Next ;_ArrayDisplay($aArray, "example array") ; Make header and insert to array (when needed) Local $sHeader = "Column 0|Column 1|Column 2|Column 3|Column 4" _ArrayInsert($aArray, 0, $sHeader) If @error Then Exit MsgBox(16, "@error: " & @error, "Something went wrong with _ArrayInsert()") Local $sOut = _StringToTable($aArray, 3, @TAB, "C,C,C,C,C") ConsoleWrite($sOut & @CRLF & @CRLF) ┌──────────┬──────────┬──────────┬──────────┬──────────┐ │ Column 0 │ Column 1 │ Column 2 │ Column 3 │ Column 4 │ ├──────────┼──────────┼──────────┼──────────┼──────────┤ │ 0-0 │ 0-1 │ 0-2 │ 0-3 │ 0-4 │ │ 1-0 │ 1-1 │ 1-2 │ 1-3 │ 1-4 │ │ 2-0 │ 2-1 │ 2-2 │ 2-3 │ 2-4 │ │ 3-0 │ 3-1 │ 3-2 │ 3-3 │ 3-4 │ │ 4-0 │ 4-1 │ 4-2 │ 4-3 │ 4-4 │ │ 5-0 │ 5-1 │ 5-2 │ 5-3 │ 5-4 │ │ 6-0 │ 6-1 │ 6-2 │ 6-3 │ 6-4 │ │ 7-0 │ 7-1 │ 7-2 │ 7-3 │ 7-4 │ │ 8-0 │ 8-1 │ 8-2 │ 8-3 │ 8-4 │ │ 9-0 │ 9-1 │ 9-2 │ 9-3 │ 9-4 │ └──────────┴──────────┴──────────┴──────────┴──────────┘ Example4: Example floating point format $sData = "" ; from https://www.autoitscript.com/forum/topic/212833-json-udf-using-json-c/#findComment-1542670 $sData &= " name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range |" & @CRLF $sData &= " StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 |" & @CRLF $sData &= " jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 |" & @CRLF $sData &= " JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 |" & @CRLF $sData &= " pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 |" & @CRLF $sData &= " JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 |" & @CRLF $sOut = _StringToTable($sData, 3, "|", "L,3,2,3,3,3,3,3") ConsoleWrite($sOut & @CRLF & @CRLF) ┌──────────────────────┬──────────┬────────┬──────────┬───────────┬────────┬─────────┬────────┐ │ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range │ ├──────────────────────┼──────────┼────────┼──────────┼───────────┼────────┼─────────┼────────┤ │ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 │ │ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 │ │ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 │ │ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 │ │ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 │ └──────────────────────┴──────────┴────────┴──────────┴───────────┴────────┴─────────┴────────┘ Made with ❤️ for readable and elegant output. ; https://www.autoitscript.com/forum/topic/212876-_stringtotable/ ;---------------------------------------------------------------------------------------- ; Title...........: _StringToTable.au3 ; Description.....: Converts a string to a formatted table with alignment and frame options. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.5 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Array.au3> #include <String.au3> Example1() ; Example string to table ;~ Example2() ; Example 2D array to table ;~ Example3() ; Example 1D array to table ;~ Example4() ; Example floating point format ;~ Example5() ; Example for new frame style ;--------------------------------------------------------------------------------------- Func Example1() ; Example string to table Local $sSum, $sOut Local $sData = _ "Company" & @TAB & "Contact" & @TAB & "Revenue" & @CRLF & _ "Alfreds Futterkiste" & @TAB & "Maria Anders" & @TAB & "1200" & @CRLF & _ "Centro Moctezuma" & @TAB & "Francisco Chang" & @TAB & "950" & @CRLF & _ "Island Trading" & @TAB & "Helen Bennett" & @TAB & "15800" $sOut = _StringToTable($sData, 0, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) $sSum &= $sOut & @CRLF & @CRLF $sOut = _StringToTable($sData, 1, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) $sSum &= $sOut & @CRLF & @CRLF $sOut = _StringToTable($sData, 2, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) $sSum &= $sOut & @CRLF & @CRLF & @CRLF $sSum &= "Notes: For the correct display of output, it is recommended to use a MonoSpace font." & @CRLF $sSum &= "Window MonoSpace font: Consolas, DejaVu Sans Mono, Courier New, Lucida Console" & @CRLF ClipPut($sSum) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example1 ;--------------------------------------------------------------------------------------- Func Example2() ; Example 2D array to table ; Make example array Local $aArray[10][5] For $i = 0 To 9 For $j = 0 To 4 $aArray[$i][$j] = $i & "-" & $j Next Next ;_ArrayDisplay($aArray, "example array") ; Make header and insert to array (when needed) Local $sHeader = "Column 0|Column 1|Column 2|Column 3|Column 4" _ArrayInsert($aArray, 0, $sHeader) If @error Then Exit MsgBox(16, "@error: " & @error, "Something went wrong with _ArrayInsert()") Local $sOut = _StringToTable($aArray, 3, -1, "C,C,C,C,C") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example2 ;--------------------------------------------------------------------------------------- Func Example3() ; Example 1D array to table Local $sMonth = "Months, January, February, March, April, May, June, July, August, September, October, November, December" Local $aMonth = StringSplit($sMonth, ", ", 3) Local $sOut = _StringToTable($aMonth, 3, -1, "C") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example3 ;--------------------------------------------------------------------------------------- Func Example4() ; Example floating point format Local $sData = "" ; from https://www.autoitscript.com/forum/topic/212833-json-udf-using-json-c/#findComment-1542670 $sData &= " name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range |" & @CRLF $sData &= " StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 |" & @CRLF $sData &= " jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 |" & @CRLF $sData &= " JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 |" & @CRLF $sData &= " pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 |" & @CRLF $sData &= " JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 |" & @CRLF Local $sOut = _StringToTable($sData, 3, "|", "L,3,2,3,3,3,3,3") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example4 ;--------------------------------------------------------------------------------------- Func Example5() ; Example for new frame style Local $sData = "" ; from https://www.autoitscript.com/forum/topic/212833-json-udf-using-json-c/#findComment-1542670 $sData &= " name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range |" & @CRLF $sData &= " StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 |" & @CRLF $sData &= " jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 |" & @CRLF $sData &= " JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 |" & @CRLF $sData &= " pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 |" & @CRLF $sData &= " JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 |" & @CRLF Local $sOut = _DblFrame($sData, "|", "L,3,2,3,3,3,3,3") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example5 ;--------------------------------------------------------------------------------------- ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _StringToTable ; Description....: Converts a string or array to a formatted table with alignment and frame options. ; Syntax.........: _StringToTable( $vString [, $iFrame = 2 [, $sSeparator = @TAB [, $sAlign = ""]]] ) ; Parameters.....: $vString - The input string or array containing data values. ; $iFrame - [optional] Frame type (0=NoFrame, 1=FrameNoHeader, 2=FrameAndHeader. (Default is 2) ; $sSeparator - [optional] Separator used in the input string. (Default is @TAB) ; $sAlign - [optional] Alignment options for each column "L,R,C,[0-9]". (Default is "" (left-aligned)) ; Return values..: The formatted table as a string. ; Author ........: ioa747 ; Notes .........: For the correct display of output, it is recommended to use a MonoSpace font. ; Window MonoSpace font: Consolas, DejaVu Sans Mono, Courier New, Lucida Console ; Link ..........: https://www.autoitscript.com/forum/topic/212876-_stringtotable/ ; Dependencies...: __FormatCell() ;-------------------------------------------------------------------------------------------------------------------------------- Func _StringToTable($vString, $iFrame = 2, $sSeparator = @TAB, $sAlign = "") ;Local $hTimer = TimerInit() If $iFrame < 0 Or $iFrame > 2 Or $iFrame = Default Then $iFrame = 2 If $sSeparator = Default Or $sSeparator = -1 Then $sSeparator = @TAB ; Convert array to string If IsArray($vString) Then Local $b2D = (UBound($vString, 0) = 1 ? False : True) If Not $b2D Then _ArrayColInsert($vString, 1) $vString = _ArrayToString($vString, $sSeparator) EndIf ;Prepare string $vString = StringRegExpReplace($vString, "(\r\n|\n)", @CRLF) $vString = StringReplace($vString, $sSeparator & @CRLF, @CRLF) $vString = StringReplace($vString, @CRLF & $sSeparator, @CRLF) $vString = StringStripCR(StringRegExpReplace($vString, "(\r\n)$", "")) ;ConsoleWrite($vString & @CRLF) Local $aRows = StringSplit($vString, @LF, 1) If $aRows[0] = 0 Then Return SetError(1, 0, "") Local $aTable[UBound($aRows)][0] Local $iLen, $iCols = 0 ; initialize rows and columns For $i = 1 To $aRows[0] Local $aCols = StringSplit($aRows[$i], $sSeparator, 1) If $i = 1 Then $iCols = $aCols[0] ReDim $aTable[$aRows[0]][$iCols] Else If $aCols[0] < $iCols Then ReDim $aCols[$iCols + 1] ;** EndIf For $j = 0 To $iCols - 1 $aTable[$i - 1][$j] = StringStripWS($aCols[$j + 1], 3) Next Next ; find the max column widths Local $aColWidths[$iCols] For $j = 0 To $iCols - 1 $aColWidths[$j] = 0 For $i = 0 To UBound($aTable) - 1 $iLen = StringLen($aTable[$i][$j]) If $aColWidths[$j] < $iLen Then $aColWidths[$j] = $iLen Next Next ; Alignment initialize Local $aAlign[$iCols] If $sAlign <> "" Then Local $aRawAlign = StringSplit($sAlign, ",", 2) Local $iRawCnt = UBound($aRawAlign) For $j = 0 To $iCols - 1 If $j >= $iRawCnt Then $aAlign[$j] = "L" Else $aAlign[$j] = StringStripWS($aRawAlign[$j], 3) If Not StringRegExp($aAlign[$j], "(?i)^(L|R|C|[0-9])$") Then $aAlign[$j] = "L" If StringRegExp($aAlign[$j], "^([0-9])$") Then ; re-find the max column widths For $i = 0 To UBound($aTable) - 1 $iLen = StringLen(StringFormat("%." & $aAlign[$j] & "f", $aTable[$i][$j])) $aColWidths[$j] = $aColWidths[$j] > $iLen ? $aColWidths[$j] : $iLen Next EndIf EndIf Next Else For $j = 0 To $iCols - 1 $aAlign[$j] = "L" Next EndIf Local Const $TL = "┌", $TR = "┐", $BL = "└", $BR = "┘", $H = "─", $V = "│", _ $C = "┼", $TH = "┬", $CH = "┴", $LH = "├", $RH = "┤" Local $bHeader = ($iFrame = 2) Local $bBorder = ($iFrame = 1 Or $iFrame = 2) Local $sPre = ($iFrame = 0 ? "" : " ") Local $sResult = "" ; Top border If $bBorder Then $sResult &= $TL For $j = 0 To $iCols - 1 $sResult &= _StringRepeat($H, $aColWidths[$j] + 2) $sResult &= ($j < $iCols - 1) ? $TH : $TR Next $sResult &= @LF EndIf ; Header row If $bHeader Then If $bBorder Then $sResult &= $V For $j = 0 To $iCols - 1 $sResult &= $sPre & __FormatCell($aTable[0][$j], $aColWidths[$j], $aAlign[$j]) & " " If $j < $iCols - 1 Then $sResult &= ($bBorder ? $V : "") Next If $bBorder Then $sResult &= $V $sResult &= @LF ; Header separator If $bBorder Then $sResult &= $LH For $j = 0 To $iCols - 1 $sResult &= _StringRepeat($H, $aColWidths[$j] + 2) If $j < $iCols - 1 Then $sResult &= ($bBorder ? $C : "") Else If $bBorder Then $sResult &= $RH EndIf Next $sResult &= @LF EndIf ; Data rows For $i = ($bHeader ? 1 : 0) To UBound($aTable) - 1 If $bBorder = 2 Then $sResult &= $V For $j = 0 To $iCols - 1 $sResult &= $sPre & __FormatCell($aTable[$i][$j], $aColWidths[$j], $aAlign[$j]) & " " If $j < $iCols - 1 Then $sResult &= $bBorder ? $V : "" Next If $bBorder Then $sResult &= $V $sResult &= @LF Next ; Bottom border If $bBorder Then $sResult &= $BL For $j = 0 To $iCols - 1 $sResult &= _StringRepeat($H, $aColWidths[$j] + 2) $sResult &= ($j < $iCols - 1) ? $CH : $BR Next EndIf ;$sResult = BinaryToString(StringToBinary($sResult, 4), 1) ; * ?? ;ConsoleWrite("> processed in: " & Round(TimerDiff($hTimer)) & " ms " & @LF) Return $sResult EndFunc ;==>_StringToTable ;--------------------------------------------------------------------------------------- Func __FormatCell($text, $width, $align) ; internal Local $Num = $align If StringRegExp($align, "^([0-9])$") Then $align = "N" Switch $align Case "N" ; "%.2f" If StringRegExp($text, "^[+-]?(\d*\.\d+|\d+\.?)$") Then Return StringFormat("%" & $width & "s", StringFormat("%." & $Num & "f", $text)) Else Return StringFormat("%" & $width & "s", $text) EndIf Case "R" Return StringFormat("%" & $width & "s", $text) Case "C" Local $pad = $width - StringLen($text) Local $left = Floor($pad / 2) Local $right = $pad - $left Return _StringRepeat(" ", $left) & $text & _StringRepeat(" ", $right) Case Else ; "L" Return StringFormat("%-" & $width & "s", $text) EndSwitch EndFunc ;==>__FormatCell ;--------------------------------------------------------------------------------------- Func _DblFrame($vString, $sSeparator = @TAB, $sAlign = "") ; * style template Local $sData = _StringToTable($vString, 3, $sSeparator, $sAlign) Local $aData = StringSplit($sData, @LF, 3) Local $iCnt = UBound($aData) - 1 Local $sOut For $i = 0 To $iCnt Switch $i Case 0 $aData[$i] = StringReplace($aData[$i], "┌", "╔", 1, 2) $aData[$i] = StringReplace($aData[$i], "─", "═", 0, 2) $aData[$i] = StringReplace($aData[$i], "┬", "╤", 0, 2) $aData[$i] = StringReplace($aData[$i], "┐", "╗", -1, 2) Case 2 $aData[$i] = StringReplace($aData[$i], "├", "╟", 1, 2) $aData[$i] = StringReplace($aData[$i], "┤", "╢", -1, 2) Case $iCnt $aData[$i] = StringReplace($aData[$i], "└", "╚", 1, 2) $aData[$i] = StringReplace($aData[$i], "─", "═", 0, 2) $aData[$i] = StringReplace($aData[$i], "┴", "╧", 0, 2) $aData[$i] = StringReplace($aData[$i], "┘", "╝", -1, 2) Case Else $aData[$i] = StringReplace($aData[$i], "│", "║", 1, 2) $aData[$i] = StringReplace($aData[$i], "│", "║", -1, 2) EndSwitch $sOut &= $aData[$i] & @CRLF Next $sOut = StringReplace($sOut, @CRLF, "", -1, 2) Return $sOut EndFunc ;==>_DblFrame ;--------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much Relative: https://www.autoitscript.com/forum/topic/211237-treestructuredir/1 point
-
_StringToTable
pixelsearch reacted to ioa747 for a topic
I have already identified it, and I did it. $aAlign[$j] = StringUpper(StringStripWS($aRawAlign[$j], 3)) If Not StringRegExp($aAlign[$j], "^(L|R|C|[0-3]F)$") Then $aAlign[$j] = "L" because I didn't find the right pattern thank you for that1 point -
_StringToTable
ioa747 reacted to pixelsearch for a topic
@ioa747 hello, thanks for your useful UDF (for Consolewrite & txt output) I have a suggestion concerning the 4th parameter, it could accept uppercase or lowercase characters, e.g "L,C,R" same as "l,c,r" . If not mistaken, it could be done with a single change : ; If Not StringRegExp($aAlign[$j], "^(L|R|C|[0-3]F)$") Then $aAlign[$j] = "L" If Not StringRegExp($aAlign[$j], "(?i)^(L|R|C|[0-3]F)$") Then $aAlign[$j] = "L" Couldn't wait, I already patched it on my computer1 point -
_StringToTable
ioa747 reacted to SOLVE-SMART for a topic
I appreciate this, thanks. Good point, I guess I have to create another thread. To be honest, it's not a "project" that I want to extent much or spend much time, because my personal usage of it isn't that much. Reporting BUGs would usually made by GitHub issues. Anyhow, you're right - most of the people here don't use GitHub at all, so I will create a new thread. --------------------------- ==> https://www.autoitscript.com/forum/topic/212886-udf-data-to-tableau3 --------------------------- Now I understand, thanks. I also wouldn't expect this, all fine. Good point, but why getting annoyed - not a big deal 😅 . Best regards Sven1 point -
_StringToTable
SOLVE-SMART reacted to ioa747 for a topic
I'm glad I gave you the motivation for your coding, but if you go ahead with your approach/UDF what will you do? Will you just announce it here below? Or if someone finds a problem in your script, where can they report it? I personally have no problem1 point -
_StringToTable
SOLVE-SMART reacted to argumentum for a topic
you're funny Last time I saw code for it was ( this ? yay : nay ). But I went to see your code just now and, it has arrays. Yey ! But I meant to have the set of symbols/char for a border as a set of it's own, not a choice of what the developer of the UDF came up at the time. And am not gong to code it just to show how it could be more flexible. Global $mParam[] Global $mConst[] Global $mBorder[] Those names for a UDF is asking for trouble in the future. And, should have helper functions. Am getting annoyed.1 point -
Are you annoyed by the limitations of the standard Windows message dialog created by MsgBox? Would you like to have coloured backgrounds and text? To choose the justification and font? Do you want to be able to place the message box other than in the centre of the screen? Centred on your GUI, for example, or at a particular location on screen? What about having user-defined text on as many buttons as you need? And user-defined icons? Or a visible countdown of the timeout? Finally, would you like to choose whether the message box has a button on your already too-crowded taskbar? If the answer to any of these questions is "YES" then the ExtMsgBox UDF is for you! [NEW VERSION] 16 Feb 24 Changed: Some additional functionality added to the "TimeOut" parameter of _ExtMsgBox: - A positive integer sets the EMB timeout as before. - A negative integer will double the size of the countdown timer if it is used. - A colon-delimited string (eg: "10:5") will set the normal EMB timeout (first integer) and will also initially disable the EMB buttons for the required period (second integer). New UDF and examples in the zip. Older version changes: ChangeLog.txt As always, I realise nearly all of the DLL calls in these UDFs could be made by using commands in other UDFs like WinAPI.au3 - but as with all my UDFs (which you can find in my sig below) I am trying to prevent the need for any other include files. The UDF and examples (plus StringSize) in zip format: ExtMsgBox.zip Courteous comments and constructive criticisms welcome - guess which I prefer! M231 point
-
Meanwhile also source codes will be classified as malware! Microsoft Defender Antivirus has detected malware or other potentially unwanted software. For more information please see the following: https://go.microsoft.com/fwlink/?linkid=37020&name=Trojan:AutoIt/Prcablt.SD!MTB&threatid=2147740918&enterprise=1 Name: Trojan:AutoIt/Prcablt.SD!MTB ID: 2147740918 Severity: Severe Category: Trojan Path: containerfile:_C:\Coding\AU3\Internet\Mp3SearchEngine\Mp3SearchEngine v1.0.8.8.au3; containerfile:_C:\Coding\AU3\Tools\WallpaperBank\WallpaperBank v1.0.2.0.au3; file:_C:\Coding\AU3\Internet\Mp3SearchEngine2\Mp3SearchEngine_v2.0.1.1.au3; file:_C:\Coding\AU3\Internet\Mp3SearchEngine\Mp3SearchEngine v1.0.8.8.au3->(UTF-8); file:_C:\Coding\AU3\SystemInfo\CompStats\Computer Stats Utility 2.0.2.0.au3; file:_C:\Coding\AU3\Tools\HTML Imager\HTML Imager v1.0.1.1.au3; file:_C:\Coding\AU3\Tools\HTML Imager\HTML Imager v1.0.1.2.au3; file:_C:\Coding\AU3\Tools\HTML Imager\HTML Imager v1.0.1.3.au3; file:_C:\Coding\AU3\Tools\ImageSplitter\ImageSplitter v1.0.0.7.au3; file:_C:\Coding\AU3\Tools\Mp3SearchEngine\Mp3SearchEngine v1.0.9.2.au3; file:_C:\Coding\AU3\Tools\WallpaperBank\WallpaperBank v1.0.2.0.au3->(UTF-8); Detection Origin: Local machine Detection Type: Concrete Detection Source: System User: NT AUTHORITY\SYSTEM Process Name: C:\Programme\Editor\Notepad3\Notepad3.exe Security intelligence Version: AV: 1.421.1531.0, AS: 1.421.1531.0, NIS: 1.421.1531.0 Engine Version: AM: 1.1.24090.11, NIS: 1.1.24090.111 point