AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to fill a string with spaces?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
umek



Joined: 02 Oct 2004
Posts: 74

PostPosted: Mon Apr 24, 2006 8:54 am    Post subject: How to fill a string with spaces? Reply with quote

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
View user's profile Send private message
garath



Joined: 24 Mar 2005
Posts: 372
Location: germany

PostPosted: Mon Apr 24, 2006 10:12 am    Post subject: Reply with quote

Place this at the start of your Script, and it will work
Code:
AutoTrim, Off

at least on WinXP SP2
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Apr 24, 2006 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
umek



Joined: 02 Oct 2004
Posts: 74

PostPosted: Mon Apr 24, 2006 11:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group