| View previous topic :: View next topic |
| Author |
Message |
umek
Joined: 02 Oct 2004 Posts: 74
|
Posted: Mon Apr 24, 2006 8:54 am Post subject: How to fill a string with spaces? |
|
|
Hi,
I'm trying to fill a string with spaces using this code.
But it takes no effect when I replace "AddThis=X" with "AddThis=%A_Space%"
I tried AutoTrim but it's all the same. What am I doing wrong?
| Code: | AddThis=X ; %A_Space%
OutFileName=YZ
StringLen, Length, OutFileName
Number:= 30 - Length
Loop, %Number%
{
ToAdd=%addThis%%ToAdd%
}
NewName=%ToAdd%%OutFileName%
MsgBox, <%newname%>
ToAdd= |
I would be happy about any suggestion!
umek _________________ Works on my machine! |
|
| Back to top |
|
 |
garath
Joined: 24 Mar 2005 Posts: 372 Location: germany
|
Posted: Mon Apr 24, 2006 10:12 am Post subject: |
|
|
Place this at the start of your Script, and it will work
at least on WinXP SP2 |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Mon Apr 24, 2006 10:36 am Post subject: |
|
|
Note: concatenation in expressions doesn't trim out spaces:
| Code: | outFilename = yz
StringLen length, outFilename
length := 30 - length
VarSetCapacity(spaces, length, Asc(" ")) ; Nice trick, no loop!
newName := spaces . outFilename
MsgBox <%newName%> |
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
umek
Joined: 02 Oct 2004 Posts: 74
|
Posted: Mon Apr 24, 2006 11:26 am Post subject: |
|
|
Great ... I love this pool of skilled AHK users! Thanks PhiLho ... thanks garath!!!
I got it wrong, ... I only tested "AutoTrim, On" at the start position. ... I think the language seems to be my biggest problem.
The second solution is more elegant with less code.
Umek is happy again now!
On w2k SP4, too! _________________ Works on my machine! |
|
| Back to top |
|
 |
|