ycomp Posted April 27, 2008 Share Posted April 27, 2008 (edited) Hi, how would I pad a string so everything lines up? e.g. x+y = z x+y+q = well, not z so I would like 2 strings: x+y = z x+y+q = well, not z thanks Edited April 27, 2008 by ycomp Link to comment Share on other sites More sharing options...
Armand Posted April 27, 2008 Share Posted April 27, 2008 Please elaborate as i can't understand what do u mean by "Pad" [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
ycomp Posted April 27, 2008 Author Share Posted April 27, 2008 Please elaborate as i can't understand what do u mean by "Pad" sorry, pad with spaces... It is not perfectly lining up.. but it should.. I edited a few times. e.g. here is one example padding with '.' a = b dexz = f to a.......... = b dexz....... = f Link to comment Share on other sites More sharing options...
Armand Posted April 27, 2008 Share Posted April 27, 2008 (edited) welll i had that same issue once... i'd suggest using @TAB between them... ie: a&@TAB&@TAB&@TAB = b abdj&@TAB&@TAB&@TAB = 5jj the thing is... some letters are normaly bigger then others which causes issues even while using @TAB... EDIT> forgot to mention that some control's and window's spaces are different as well... thus even some more problems... If it's important enough just use a listview... the new beta made these quite easy to use! Edited April 27, 2008 by Armand [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Link to comment Share on other sites More sharing options...
weaponx Posted April 28, 2008 Share Posted April 28, 2008 You need to clarify, are you talking about fixed width fonts in the forum codebox? Or are you talking about the AutoIt MessageBox()? Link to comment Share on other sites More sharing options...
ycomp Posted April 28, 2008 Author Share Posted April 28, 2008 welll i had that same issue once... i'd suggest using @TAB between them... ie: a&@TAB&@TAB&@TAB = b abdj&@TAB&@TAB&@TAB = 5jj the thing is... some letters are normaly bigger then others which causes issues even while using @TAB... EDIT> forgot to mention that some control's and window's spaces are different as well... thus even some more problems... If it's important enough just use a listview... the new beta made these quite easy to use! ok, thanks... I will consider this thread "sovled" but if anyone does know of an functions or combination of functions that can help me do a real pad, then let me know... I mean just e.g. pad($s, 20, ".") would put up to 20 dots... hmm I'm getting lazy, I guess I could've written a function already in the amount of time it took me to write this Link to comment Share on other sites More sharing options...
ycomp Posted April 28, 2008 Author Share Posted April 28, 2008 ok, thanks... I will consider this thread "sovled" but if anyone does know of an functions or combination of functions that can help me do a real pad, then let me know... I mean just e.g. pad($s, 20, ".") would put up to 20 dots... hmm I'm getting lazy, I guess I could've written a function already in the amount of time it took me to write this I was simply talking about dealing with strings... not GUI Link to comment Share on other sites More sharing options...
xroot Posted April 28, 2008 Share Posted April 28, 2008 Maybe This will work, it has for me. Thanks StringFormat("[%10s]", $s) & @CRLF); // right-justification with spaces StringFormat("[%-10s]", $s) & @CRLF); // left-justification with spaces StringFormat("[%010s]", $s) & @CRLF); // zero-padding works on strings too StringFormat("[%10.10s]", $t) & @CRLF); // left-justification but with a cutoff of 10 characters Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 28, 2008 Share Posted April 28, 2008 Other way would be _StringRepeat(' ', 50 - StringLen($yourString)) Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 28, 2008 Share Posted April 28, 2008 Like this: #include <String.au3> Global $a = "Hello" ConsoleWrite(_stringPad($a, '.') & @CRLF) ConsoleWrite(_stringPad($a, '#', 10, 0) & @CRLF) Func _stringPad($string, $pad = ' ', $count = 10, $opt = 1) If $opt = 1 Then Return $string & _StringRepeat($pad, $count - StringLen($string)) Else Return _StringRepeat($pad, $count - StringLen($string)) & $string EndIf EndFunc ;==>_stringPad Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
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