| View previous topic :: View next topic |
| Author |
Message |
davep
Joined: 17 Mar 2010 Posts: 3
|
Posted: Wed Mar 17, 2010 4:34 pm Post subject: Separating a String Variable by Line Feed |
|
|
Hi, to make the background short, I have a string variable containing text I am populating from a Window read. This text may have several line feeds in it, which AHK understands perfectly, but which are stripped from the program I am feeding with the data. What I would like to to is take those lines and parse them out to multiple variables based on the line feeds. For Example:
------------------------------------
The contents of MyTextVar are:
Line 1
Line 2
Line 3
------------------------------------
I would like to be able read MyTextVar, and output it's contents, so that the result would be:
MyTextVar1 = Line 1
MyTextVar2 = Line 2
MyTextVar3 = Line 3
Does this make sense as I'm explaining it? I've not been able to find anything so far, is it possible? Thanks for any help you can provide.
dave |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
wooly_sammoth
Joined: 12 May 2009 Posts: 634 Location: Gloucester UK
|
Posted: Wed Mar 17, 2010 4:42 pm Post subject: |
|
|
Loop (Parse a string) is your friend.
| Code: | Loop, Parse, myTextVar, `n
{
MyTextVar%A_Index% = %A_LoopField%
} |
Edit: Or StringSplit of course |
|
| Back to top |
|
 |
davep
Joined: 17 Mar 2010 Posts: 3
|
Posted: Wed Mar 17, 2010 6:56 pm Post subject: |
|
|
| thank you! |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Wed Mar 17, 2010 7:01 pm Post subject: |
|
|
| wooly_sammoth wrote: | | Code: | Loop, Parse, myTextVar, `n, `r
{
MyTextVar%A_Index% = %A_LoopField%
} |
| IF you parse it like so ALWAYS exclude the `r character just to be sure otherwise you may end up with undesired results (and wonder why) _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
|