Popular Post ioa747 Posted May 6 Popular Post Posted May 6 (edited) _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. expandcollapse popup; 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+)?$") 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/ Edited 4 hours ago by ioa747 update to Version: 0.5 SOLVE-SMART, pixelsearch, CYCho and 8 others 11 I know that I know nothing
WildByDesign Posted May 6 Posted May 6 This is really nice. I can think of many times where this would have come in handy. It's neat that you have alignment feature too. Thanks for sharing. ioa747 1
SOLVE-SMART Posted May 6 Posted May 6 Thanks @ioa747, I like the implementation too 👍 . One little thing: In frame type/mode 0 ($iFrame = 0), the table will be generated without any frame (border). But there is a leading whitespace for each table row which is unnecessary in my opionion. Do you mind to change the code to get rid of that? Of course I could do it on my own, but maybe it's also good for all others here. What do you think? Best regards Sven ioa747 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
SOLVE-SMART Posted May 6 Posted May 6 Is it okay when I use your function to add two more modes? I would add a markdown table format and a gherkin feature table format. If I would use your code in any of my open source project, I would refer to you (naming and link). 👉 Markdown table format: Spoiler | Item | In Stock | Price | | :---------------- | :------: | ----: | | Python Hat | True | 23.99 | | SQL Hat | True | 23.99 | | Codecademy Tee | False | 19.99 | | Codecademy Hoodie | False | 42.99 | 👉 Gherkin feature table format: Spoiler Given the following users exist: | name | email | twitter | | Aslak | aslak@cucumber.io | @aslak_hellesoy | | Julien | julien@cucumber.io | @jbpros | | Matt | matt@cucumber.io | @mattwynne | Best regards Sven ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
ioa747 Posted May 6 Author Posted May 6 @SOLVE-SMART update to Version: 0.2 without leading whitespace in $iFrame = 0 16 minutes ago, SOLVE-SMART said: Is it okay when I use your function to add two more modes? Of course, feel free to use it Adding these features sounds really cool. I can't wait to see the result. SOLVE-SMART 1 I know that I know nothing
SOLVE-SMART Posted May 6 Posted May 6 48 minutes ago, ioa747 said: Of course, feel free to use it Nice, thanks. 44 minutes ago, ioa747 said: Adding these features sounds really cool. I can't wait to see the result. I will share the code, but I won't add the features to your function(s). I would use my own code style and my own use cases. Therefore not all of your frame types will be applied in my version - just to mention it 😆 . In other words, it would not be that dynamic and UDF-like, because I focus on specific use cases not on plenty of variants. Best regards Sven ioa747 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
argumentum Posted Wednesday at 12:16 AM Posted Wednesday at 12:16 AM ShellExecute("notepad.exe") ; works better Nice, nice, nice. Really liked it !. ioa747 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Solution ioa747 Posted Wednesday at 07:44 AM Author Solution Posted Wednesday at 07:44 AM (edited) 16 hours ago, ioa747 said: update to Version: 0.3 I added functionality to accept and array as input. I renamed $iString to $vString, and now it verifies whether $vString is an array and converts it to a string as needed. Edited Wednesday at 07:59 AM by ioa747 SOLVE-SMART and argumentum 2 I know that I know nothing
SOLVE-SMART Posted Wednesday at 09:18 AM Posted Wednesday at 09:18 AM 1 hour ago, ioa747 said: I added functionality to accept and array as input. I renamed $iString to $vString, and now it verifies whether $vString is an array and converts it to a string as needed. That's exactly what I would do, because (at least in my opinion) with AutoIt we handle Arrays or the array data all the time. It's more common to transform array data to such a table instead of a with TABs separated string. Thank you very much @ioa747 for v0.3 👌 . Best regards Sven ioa747 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
SOLVE-SMART Posted Wednesday at 04:17 PM Posted Wednesday at 04:17 PM (edited) On 5/6/2025 at 8:13 PM, SOLVE-SMART said: I will share the code, but I won't add the features to your function(s). I would use my own code style and my own use cases. Therefore not all of your frame types will be applied in my version - just to mention it 😆 . In other words, it would not be that dynamic and UDF-like, because I focus on specific use cases not on plenty of variants. FYI @ioa747, I created a (temporary) GitHub repository with your library (UDF functions) to find myself in a better structured way. This is my way of doing such things and has nothing to do with your previous preparation of the topic or the UDF. It simply helps me. https://github.com/sven-seyfert/data-to-table In this repo. I want to change some code parts, like I mentioned before regarding "markdown tables" or "gherkin feature tables". So I can share the diffs by commits and so on. But please don't expect too much ... your UDF is already very good and I just want to adjust that work for my specific use cases. ⚠ After that, I guess I would share the code here in the forum and would remove this temporary repository. Best regards Sven Edited Thursday at 12:39 PM by SOLVE-SMART ioa747 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
SOLVE-SMART Posted Thursday at 01:00 PM Posted Thursday at 01:00 PM Hi @ioa747 👋 , first I refactored your code to apply my code styling, but then I realized I do a complete rewrite. So I decided to create a new UDF-like function. Thanks again for your original logic and code, I will enhance the UDF by additional tables, like mentioned before. What I did so far can be found here. Best regards Sven ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
WildByDesign Posted Thursday at 01:33 PM Posted Thursday at 01:33 PM My initial thought with this was to make some elegant and beautiful MsgBox's, particularly About dialogs, etc. But I realized that the output from _stringtotable simply wasn't lining up properly in a MsgBox. So I decided try it with the ExtMsgBox UDF since it has more customizing options. That also came up all scrambled. Until... I realized that I would need to use a monospaced font like in other projects. Cascadia Mono didn't look as nice. So I did Consolas and it looked great. Basically, the following code was added: #include "ExtMsgBox.au3" _ExtMsgBoxSet(1, 4, 0x202020, 0xe0e0e0, -1, "Consolas", 1200, 1200) _ExtMsgBox (0, 0, "_ExtMsgBox", $sOut) The _ExtMsgBox (0, 0, "_ExtMsgBox", $sOut) just needed to be adapted into the right area of examples, of course. Screenshots: Spoiler So this opens up some nice possibilities for my usage of it. Thanks again for sharing this. Also, @SOLVE-SMART I am going to follow your progress on this as well. ioa747, Musashi and SOLVE-SMART 3
ioa747 Posted Thursday at 02:17 PM Author Posted Thursday at 02:17 PM On 5/6/2025 at 6:38 PM, ioa747 said: update to Version: 0.4 I added the ability for 1D array, and floating point as format , to control digits after decimal point [0-3]f e.g. 0f, for no decimal point, , 2f for 2 digits after decimal point argumentum 1 I know that I know nothing
WildByDesign Posted Thursday at 03:28 PM Posted Thursday at 03:28 PM Would you be willing to add another $iFrame option? If possible, it would be good to have an option that does a border for only the outer frame of the table. ioa747 1
argumentum Posted Thursday at 05:03 PM Posted Thursday at 05:03 PM ╔══════════════════════╦══════════╦════════╦══════════╦═══════════╦════════╦═════════╦════════╗ ║ 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 ║ ╚══════════════════════╩══════════╩════════╩══════════╩═══════════╩════════╩═════════╩════════╝ ... ... Local Const $TL = "╔", $TR = "╗", $BL = "╚", $BR = "╝" Local Const $H = "═", $V = "║", $C = "╬" Local Const $TH = "╦", $CH = "╩", $LH = "╠", $RH = "╣" ... ... Musashi and WildByDesign 2 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted Thursday at 05:16 PM Posted Thursday at 05:16 PM ╔══════════════════════╤══════════╤════════╤══════════╤═══════════╤════════╤═════════╤════════╗ ║ 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 ║ ╚══════════════════════╧══════════╧════════╧══════════╧═══════════╧════════╧═════════╧════════╝ ..that takes more coding ( edited by hand above ). The question is: how far is this going to be taken ?, ... the original is good as far as prettifying a table to separate the content from the header and delimiting columns. Other than that, what's the use ?. My 2 cents ioa747 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
SOLVE-SMART Posted Thursday at 08:30 PM Posted Thursday at 08:30 PM (edited) First of all and to clarify: I don't see this as a competition - just in case you folks would think of this regarding @ioa747 and me 😆 . On 5/8/2025 at 5:28 PM, WildByDesign said: Would you be willing to add another $iFrame option? On 5/8/2025 at 7:16 PM, argumentum said: the original is good as far as prettifying a table to separate the content from the header and delimiting columns. Other than that, what's the use I agree. I guess extending the border styles (frame types) is just a gimmick. Nevertheless, I played a bit with my version of DataToTable.au3 which lead to v0.2.0. In the README.md section output-result you can see a fourth border style "4=BorderAndHeaderEdgesWithAccent" as a example. In the CHANGELOG.md you will find how I changed it. To achieve the styling above (shared by @argumentum) it would lead to some more code adjustments, but at the moment I don't have the desire to implement it - sorry @WildByDesign 😅 . Best regards Sven Edited Friday at 09:13 PM by SOLVE-SMART argumentum, ioa747, Musashi and 1 other 4 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
ioa747 Posted Friday at 05:06 AM Author Posted Friday at 05:06 AM 13 hours ago, WildByDesign said: it would be good to have an option that does a border for only the outer frame of the table. I agree with argumentum above, it's easier to do everything with double lines, than just the outline. Adding more frame types, requires more nested if, then , which has implications for all frame types. I'm thinking of removing frame =2 as well, right now it doesn't seem appealing to me, it will reduce both response time and readability of the script. as well However, the idea is not bad, and it's nice to get what you want. For this (and for the coding challenge) in the next version I will put a helper function that will do it. Which, (those reading) can have by now expandcollapse popup#include <Array.au3> #include <String.au3> _test() ;--------------------------------------------------------------------------------------- Func _test() Local $sTxt, $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 = _DblFrame($sData, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) EndFunc ;==>_test ;--------------------------------------------------------------------------------------- Func _DblFrame($vString, $sSeparator = @TAB, $sAlign = "") 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 Return $sOut EndFunc ;==>_DblFrame argumentum, SOLVE-SMART, WildByDesign and 1 other 3 1 I know that I know nothing
WildByDesign Posted Friday at 12:35 PM Posted Friday at 12:35 PM 7 hours ago, ioa747 said: in the next version I will put a helper function that will do it. Which, (those reading) can have by now I've tested your _DblFrame function this morning and it works great and looks really nice. ioa747 1
SOLVE-SMART Posted Friday at 09:28 PM Posted Friday at 09:28 PM (edited) Hi folks 👋 , I spend a bit freetime and created version v0.3.0 of data-to-table.au3 UDF. 8 different border styles a flexible way of adding more border styles (tiny how-to follows in the next days (I hope)) what has changed ==> CHANGELOG how it looks ==> output-result Once again, kudos to @ioa747 for his idea and main logic behind it. I changed your version drastically, but you approach is still in my coding heart 🤭 . 💡 For now, I am temporary done with this library, until I will have more time for this. If you guys find BUGs or do have suggestions, I really appreciate your feedback - thanks 🤝 . Btw. @WildByDesign, your style request from @argumentums post here, is border style variant 8 "double-outter-border-and-header-with-single-inner-border" 😀 . ╔════════════╤════════════════╤═════════════════╤═════════════════════════════════════════╗ ║ 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 ║ ╚════════════╧════════════════╧═════════════════╧═════════════════════════════════════════╝ If you like the UDF, consider to star the project on GitHub, thanks. Best regards Sven Edited Friday at 09:30 PM by SOLVE-SMART WildByDesign 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now