WildByDesign Posted May 9 Posted May 9 1 hour ago, SOLVE-SMART said: border style variant 8 "double-outter-border-and-header-with-single-inner-border" My request was 9 "outside-border-only" which I just submitted as a PR. Thank you for making your UDF extensible because it was very easy to add a new border style. Another possible idea might be similar to 9 "outside-border-only" but with a double outer border.
argumentum Posted May 9 Posted May 9 (edited) 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" Spoiler ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒ 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 ▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ...did look better in notepad Edited May 10 by argumentum more WildByDesign, Musashi and SOLVE-SMART 3 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
SOLVE-SMART Posted May 10 Posted May 10 (edited) On 5/10/2025 at 12:54 AM, WildByDesign said: My request was 9 "outside-border-only" which I just submitted as a PR. Thanks for the PR @WildByDesign 👌 . One question before merging, see PR conversation. On 5/10/2025 at 12:54 AM, WildByDesign said: Thank you for making your UDF extensible because it was very easy to add a new border style. That's exactly my thoughts. Now people can come up with other styles by their own and add them easily 😀 . On 5/10/2025 at 1:41 AM, argumentum said: 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" ? I don't get it @argumentum 🤔 ... what do you exactly mean? Because at the moment there is already a array table for the borders/chars which can be adjusted easily. Best regards Sven @ioa747: Should I create another thread for my approach/UDF? Because I don't want to hijack or disturb your original topic 😇 . Edited Monday at 12:06 PM by SOLVE-SMART ==> 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 May 10 Posted May 10 10 minutes ago, SOLVE-SMART said: Should I create another thread for my approach/UDF? Because I don't want to hijack or disturb your original topic 😇 . you're funny 10 minutes ago, SOLVE-SMART said: I don't get it @argumentum 🤔 ... what do you exactly mean? Because at the moment there is already a array table for the borders/chars which can be adjusted easily. 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. SOLVE-SMART 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted May 10 Author Posted May 10 (edited) 1 hour ago, SOLVE-SMART said: Should I create another thread for my approach/UDF? 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 problem Edited May 10 by ioa747 SOLVE-SMART 1 I know that I know nothing
SOLVE-SMART Posted May 10 Posted May 10 (edited) On 5/10/2025 at 11:17 AM, ioa747 said: I'm glad I gave you the motivation for your coding I appreciate this, thanks. On 5/10/2025 at 11:17 AM, ioa747 said: 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? 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 --------------------------- On 5/10/2025 at 10:32 AM, argumentum said: 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. Now I understand, thanks. On 5/10/2025 at 10:32 AM, argumentum said: And am not gong to code it just to show how it could be more flexible. I also wouldn't expect this, all fine. On 5/10/2025 at 10:32 AM, argumentum said: 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. Good point, but why getting annoyed - not a big deal 😅 . Best regards Sven Edited Monday at 12:08 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)
pixelsearch Posted May 10 Posted May 10 (edited) @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 computer Edited May 10 by pixelsearch typo ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
ioa747 Posted May 10 Author Posted May 10 (edited) 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 that Edited May 10 by ioa747 pixelsearch 1 I know that I know nothing
pixelsearch Posted May 10 Posted May 10 (edited) Glad we thought alike Wish I entered this thread earlier, to suggest 0-9 (instead of 0-3) and also a 4th parameter string without "F" at all, so the user doesn't need to type all the useless "F", then the code could be : ; $sOut = _StringToTable($sData, Default, Default, "C, 2F, 6F, 3F, 3F, 0F") $sOut = _StringToTable($sData, Default, Default, "c, 2, 6, 3, 3, 0") Now the 4th parameter, when splitted, is composed in all cases of only 1 character (easier to handle in UDF), then you can add the mandatory lowercase "f" for StringFormat where needed in __FormatCell() I guess it's a bit late to think about it and after all, if someone (me !) wants to get rid of the numerous "F", he can tweak your UDF at his wish. The "problem" when tweaking the UDF is that each time you'll upload a new release, all personal tweaks should be re-applied to the new release. That's why I start keeping your original source code (starting with version 0.4) in a read-only file, like this : When you'll upload version 0.5, then I'll save it to a new protected file (guess its name !) and compare it to your preceding version 0.4, so I can apply your new changes to my personal version (instead of applying my numerous tweaks to your new version) For the record, I got already another mandatory tweak, for instance : ; ConsoleWrite($sOut & @CRLF & @CRLF) ConsoleWrite(BinaryToString(StringToBinary($sOut, 4), 1) & @crlf & @crlf) Probably a wrong code page on my computer (or I don't know what), but I won't spend any more time to fix this on my computer, it's just wasted time. Glad @jchd suggested once the "BinaryToString(StringToBinary())" way to solve this, it works fine, all the time, thanks jchd ! For the record (ioa747) I'm very happy with the "box-drawing characters" you choosed for your UDF. I'm not into the "double line" characters at all but I understand some users like them a lot. To each his own and everybody's happy. Thanks for reading and have a great evening Edited May 10 by pixelsearch typo ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
SOLVE-SMART Posted May 10 Posted May 10 (edited) 51 minutes ago, pixelsearch said: The "problem" when tweaking the UDF is that each time you'll upload a new release, all personal tweaks should be re-applied to the new release. That's why I start keeping your original source code (starting with version 0.4) in a read-only file May I suggest: Exactly to handle such behavior GIT (or another version control system) come into play. You would make your live so much easier and you also have the chance to contribute or let others contribute to your code (by branches, code reviews, pull requests and so on). But by the way ... 51 minutes ago, pixelsearch said: ConsoleWrite(BinaryToString(StringToBinary($sOut, 4), 1) & @crlf & @crlf) ... that's a really good recommendation 👌 . Best regards Sven Edited May 10 by SOLVE-SMART ==> 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 Sunday at 04:38 AM Author Posted Sunday at 04:38 AM 9 hours ago, pixelsearch said: to suggest 0-9 (instead of 0-3) This is the only easy one. All that is needed is to make the following from 3 to 9 If Not StringRegExp($aAlign[$j], "(?i)^(L|R|C|[0-9]F)$") Then $aAlign[$j] = "L" 9 hours ago, pixelsearch said: and also a 4th parameter string without "F" at all, so the user doesn't need to type all the useless "F" in this topic I am still in the search I thought maybe I should add other types of formats, or even just pass the raw format pattern, I don't know. e.g.: expandcollapse popup... Else $aAlign[$j] = StringStripWS($aRawAlign[$j], 3) If Not StringRegExp($aAlign[$j], "(?i)^(L|R|C|[0-9]f|[0-9]i)$") Then $aAlign[$j] = "L" $iLen = StringLen($aRawAlign[$j]) If $iLen > 1 Then ; compo format $sCompo = StringRight($aRawAlign[$j], 1) ; re-find the max column widths Switch $sCompo Case "f" For $i = 0 To UBound($aTable) - 1 $iLen = StringLen(StringFormat("%." & StringLower($aRawAlign[$j]), $aTable[$i][$j])) $aColWidths[$j] = $aColWidths[$j] > $iLen ? $aColWidths[$j] : $iLen Next Case "i" For $i = 0 To UBound($aTable) - 1 $iLen = StringLen(StringFormat("%0" & StringLower($aRawAlign[$j]), $aTable[$i][$j])) $aColWidths[$j] = $aColWidths[$j] > $iLen ? $aColWidths[$j] : $iLen Next EndSwitch EndIf EndIf ... ... Func __FormatCell($text, $width, $align) ; internal Local $sCompo, $iLen $iLen = StringLen($align) ;check composite $align If $iLen > 1 Then $sCompo = $align $align = StringRight($align, $iLen - 1) EndIf Switch $align Case "I" ; "%09i" If StringRegExp($text, "^-?\d+?$") Then Return StringFormat("%" & $width & "s", StringFormat("%0" & StringLower($sCompo), $text)) Else Return StringFormat("%" & $width & "s", $text) EndIf Case "F" ; "%.2f" If StringRegExp($text, "^-?\d+(\.\d+)?$") Then Return StringFormat("%" & $width & "s", StringFormat("%." & StringLower($sCompo), $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 What is your opinion? 9 hours ago, pixelsearch said: For the record, I got already another mandatory tweak, for instance : ; ConsoleWrite($sOut & @CRLF & @CRLF) ConsoleWrite(BinaryToString(StringToBinary($sOut, 4), 1) & @crlf & @crlf) you propose ? Return BinaryToString(StringToBinary($sResult, 4), 1) Thank you very much for the creative thinking. I know that I know nothing
pixelsearch Posted Sunday at 08:25 AM Posted Sunday at 08:25 AM 3 hours ago, ioa747 said: What is your opinion? I won't be at home all day (spending some nice time with family) so I'll take a deep look at your post tomorrow. Just a word concerning BinaryToString(StringToBinary()) : as noone else complained about the Console output, I suggest you do nothing for now. Have a great sunday ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
Jury Posted Sunday at 04:49 PM Posted Sunday at 04:49 PM Any hints on changing out put to <table> format for html documents? I'm struggling to understand $sSeparator in _StringToTable. Is this possible even?
ioa747 Posted Sunday at 04:51 PM Author Posted Sunday at 04:51 PM give example I know that I know nothing
Jury Posted Sunday at 05:28 PM Posted Sunday at 05:28 PM (edited) Haven't got any output legible yet tried to replace " " with hex A0s thinking that would preserve spacing so the result would work in a <pre> </pre> section in a html file but its a mess. It seems that there would have to be differing types of $sSeparator if it is going to output a html table such as the attached test.html the added advantage is this can be done is that the resultant html table can be copy and pasted into Word files (as I've done in word_table.docx). test.htmlword_table.docx Edited Sunday at 05:29 PM by Jury
ioa747 Posted Sunday at 05:45 PM Author Posted Sunday at 05:45 PM (edited) if you open the .html in the browser then you can mark the text with the mouse, copy Then you can proceed with Func Example7() ; Example from clopboard Local $sData = ClipGet() Sleep(100) $sOut = _StringToTable($sData) ConsoleWrite($sOut & @CRLF & @CRLF) EndFunc if you want to extract it from the source code <html> <head> <title></title> </head> <body> <p><BR></p> <table border=1> <tr><td> name �</td><td align=right> time[ms]�</td><td align=right> factor�</td><td align=right> Std. Dev�</td><td align=right> Std. Err.�</td><td align=right> min�</td><td align=right> max�</td><td align=right> range�</td></tr> <tr><td> StringRegExp only </td><td align=right> 1.691 </td><td align=right> 1.00 </td><td align=right> 0.351 </td><td align=right> 0.035 </td><td align=right> 1.304 </td><td align=right> 3.167 </td><td align=right> 1.863 </td></tr> <tr><td> jq UDF </td><td align=right> 32.933 </td><td align=right> 19.48 </td><td align=right> 2.929 </td><td align=right> 0.293 </td><td align=right> 29.308 </td><td align=right> 43.169 </td><td align=right> 13.861 </td></tr> <tr><td> JsonC-UDF </td><td align=right> 51.086 </td><td align=right> 30.21 </td><td align=right> 3.205 </td><td align=right> 0.321 </td><td align=right> 45.625 </td><td align=right> 63.460 </td><td align=right> 17.835 </td></tr> <tr><td> pure AutoIt JSON-UDF </td><td align=right> 97.916 </td><td align=right> 57.90 </td><td align=right> 5.685 </td><td align=right> 0.569 </td><td align=right> 86.362 </td><td align=right> 113.467 </td><td align=right> 27.105 </td></tr> <tr><td> JSMN-based JSON-UDF </td><td align=right> 108.248 </td><td align=right> 64.01 </td><td align=right> 5.512 </td><td align=right> 0.551 </td><td align=right> 99.029 </td><td align=right> 130.864 </td><td align=right> 31.835 </td></tr> </table> </body> </html> then you will need to make a parser that will clean up the tags, and bring it into a format where it will be clear where the table data begins, what is the column separator, what is the row separator Edited Sunday at 06:07 PM by ioa747 I know that I know nothing
pixelsearch Posted Monday at 11:11 AM Posted Monday at 11:11 AM On 5/11/2025 at 5:38 AM, ioa747 said: I thought maybe I should add other types of formats, or even just pass the raw format pattern, I don't know. On 5/8/2025 at 6:16 PM, argumentum said: 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 Hello, just watch out or it may turn out to a Pändora box. In fact your UDF could be used by 2 different kind of users : 1) The users who need a simple 4th parameter (and no headache) containing only 1 character between the commas, for example "L, C, R, 2, 3, 5, 2" 2, 3, 5, 2 are the number of decimals (most numeric columns are placed at the right, especially those with decimals [as you do now] because of the decimals alignment) In this 1st case, after you split the 4th parameter to an array (as you already do) then all elements of the array are only 1 character long, so far so good and no headache. 2) The users who master StringFormat (not my case) and indicate the StringFormat syntax directly inside the 4th parameter, for example "L, C, R, %09i, %x, %.2f" In this second case, after you split the 4th parameter to an array, any element having its length > 1 should be considered as a correct StringFormat format control, that you could "easily" apply directly to the cell. But now, maybe you'll have a lot of work with this, because you'll have to calculate the resulting length of any valid StringFormat indicated by the user (the Pandora box !) So I guess it's your choice to know exactly where you want to go with your UDF, keeping it simple or not ? If I may, here are a few notes I wrote while studying a bit your UDF this morning : ============= ; If $iFrame < 0 Or $iFrame > 3 Then $iFrame = 3 ; If $sSeparator = Default Or $sSeparator = -1 Then $sSeparator = @TAB If $iFrame = Default Then $iFrame = 3 If $sSeparator = Default Then $sSeparator = @TAB If $iFrame < 0 Or $iFrame > 3 Then Return SetError(...) ============= Example3 (1D) As any 1D array is turned to a 2D array by the UDF (before being turned to a string using _ArrayToString) then actually you force the separator to be "|" to have a correct output : Local $sOut = _StringToTable($aMonth, 3, "|", "C") ; actual example found in the original UDF script If the user makes a "mistake" and chooses another separator (like @Tab) Then the output will be incorrect : Local $sOut = _StringToTable($aMonth, 0, Default, "C") ; user's script, Default means @Tab Incorrect user's output (showing a "|" at the right of each row) Months| January| February| March| But if you apply the following change in the UDF, then the output seems always correct, no matter the delimiter chosen by the user : ; If $b2D Then ; $vString = _ArrayToString($vString, $sSeparator) ; Else ; _ArrayColInsert($vString, 1) ; $vString = _ArrayToString($vString) ; EndIf If Not $b2D Then _ArrayColInsert($vString, 1) ; 1D => 2D $vString = _ArrayToString($vString, $sSeparator) ; same code for both cases ============= A missing Local in example4 (Local $sData = "") Opt("MustDeclareVars", 1) would detect this but I'm not sure you can use this Opt in an UDF as it would create issues in many users scripts which don't use it. ============= If $aCols[0] < $iCols Then ReDim $aCols[$iCols + 1] ; For $k = $aCols[0] + 1 To $iCols ; not needed ; $aCols[$k] = "" ; not needed ; Next ; not needed $aCols[0] = $iCols ; missing line (though maybe not useful) EndIf ============= Once again, please accept my apologies for any incorrect note above, thank you. And bravo for this great UDF ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
ioa747 Posted Monday at 02:51 PM Author Posted Monday at 02:51 PM On 5/6/2025 at 6:38 PM, ioa747 said: update to Version: 0.5 I removed the unnecessary frame formats and kept the basic ones 0=NoFrame, 1=FrameNoHeader, 2=FrameAndHeader. I removed the extra f, from the alignment format, for the decimals, and now we simply put the number, for how many digits we want after the decimal point [0-9]. e.g. "L,1,2,3" and I got into the philosophy, make it simple pixelsearch 1 I know that I know nothing
pixelsearch Posted Tuesday at 03:40 AM Posted Tuesday at 03:40 AM Hello @ioa747 Example 4, first number is 1.691 If we replace this number with .6 (for example) then the following test in __FormatCell() will fail : If StringRegExp($text, "^-?\d+(\.\d+)?$") Then The output will be .6 instead of 0.600 Same for numbers like +6 or 12. etc... (though 12. shouldn't happen too often but who knows...) I tried this pattern which seems to cover all 4 cases : If StringRegExp($text, "^[+-]?(\d*\.\d+|\d+\.?)$") Then 4 cases being : 12.34 12. 12 .34 ...preceded by an optional + or - sign Could you please try it to see if it suits you ? Thanks and have a great day ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
ioa747 Posted Tuesday at 05:55 AM Author Posted Tuesday at 05:55 AM Congratulations 🥇 @pixelsearch Thank you very much. Very insightful, my mind didn't go there. When I was building this pattern my mind was, not to catch the heading I updated the original (in the same version) 👈 pixelsearch 1 I know that I know nothing
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