 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Hound
Joined: 15 Apr 2005 Posts: 4
|
Posted: Mon Apr 18, 2005 10:59 am Post subject: String Formatting Question |
|
|
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 |
|
 |
BoBo Guest
|
Posted: Mon Apr 18, 2005 12:11 pm Post subject: |
|
|
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.   |
|
| Back to top |
|
 |
niwi
Joined: 27 Feb 2005 Posts: 128 Location: Heidelberg, Germany
|
Posted: Mon Apr 18, 2005 12:37 pm Post subject: |
|
|
Hi,
| Code: |
StringGetPos, pos, Name, %A_Space%
If pos > 0
StringLeft, Name, Name, (pos - 1)
|
untested...
NiWi. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|