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 

String Formatting Question

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



Joined: 15 Apr 2005
Posts: 4

PostPosted: Mon Apr 18, 2005 10:59 am    Post subject: String Formatting Question Reply with quote

How would I go about writing code that evaluates a string as "If the string contains a space, delete everything to the right of that space including that space, else move on to the rest of the script". Ive tried using my own little formatting block for this but with no success:
Code:
FormatLoop:
 StringMid, Char, Name, %Counter%, 1
 if Char = %A_Space%
  {
   X= %length% - %Counter% + 1
  StringTrimRight, Name, Name, %X%
  }
 else
 {
   if %Counter% <= %length%
   {
   Counter +=1
   Goto, FormatLoop
   }
 }
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Mon Apr 18, 2005 12:11 pm    Post subject: Reply with quote

That'll work if there's only one space per line.
Code:


Loop, Read, My.txt
{
    IfInString, A_LoopReadLine, %A_Space%
    {
        StringSplit, Field, A_LoopReadLine, %A_Space%
        MsgBox, %A_LoopReadLine%`nThat's right from the space character:%Field2%
    }
}
Braindump. Untested. Rolling EyesWink
Back to top
niwi



Joined: 27 Feb 2005
Posts: 128
Location: Heidelberg, Germany

PostPosted: Mon Apr 18, 2005 12:37 pm    Post subject: Reply with quote

Hi,

Code:

StringGetPos, pos, Name, %A_Space%
If pos > 0
 StringLeft, Name, Name, (pos - 1)


untested...

NiWi.
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