 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Sun Jul 06, 2008 7:05 pm Post subject: How to insert a variable into every line of a lisbox? |
|
|
I need to retrieve data from a list box then insert a constant variable into every line of that list box. The data is then appended to a file. Here is how I am retrieving the data.
| Code: | | ControlGet,servers,list,,ListBox1, |
Here is the listbox content.
server1
server2
server3
server4
Here is what I need. The constant is "grid".
grid,server1,
grid,server2,
grid,server3,
grid,server4,
Any help? |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sun Jul 06, 2008 7:27 pm Post subject: |
|
|
Look up Loop, Parse and FileAppend
HTH |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Sun Jul 06, 2008 8:38 pm Post subject: |
|
|
| Can you give me an example? |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Sun Jul 06, 2008 9:25 pm Post subject: I need to retrieve data from a edit box |
|
|
Ok.. I canged my mind. I am going to use a Edit box instead of a Listbox. So here is my question.
I need to retrieve data from a edit box then insert a constant variable into every line of that edit box data. The data is then appended to a file. Here is how I am retrieving the data.
| Code: | | GuiControlGet,servers,,Edit1, |
Here is the Edit box content.
server1
server2
server3
server4
Here is what I need as a result. The constant is "grid".
grid,server1,
grid,server2,
grid,server3,
grid,server4,
Any help? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6084
|
Posted: Sun Jul 06, 2008 9:38 pm Post subject: |
|
|
| Code: | servers=
(
server1
server2
server3
server4
)
loop, parse, servers, `n, `r
new .= "grid," a_loopfield "`n"
msgbox, % new |
 _________________
 |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Sun Jul 06, 2008 10:05 pm Post subject: |
|
|
| Sorry I should had specified. Grid comes from a variable %grid%. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6084
|
Posted: Sun Jul 06, 2008 10:26 pm Post subject: |
|
|
| Code: | servers=
(
server1
server2
server3
server4
)
loop, parse, servers, `n, `r
new .= grid "," a_loopfield "`n"
msgbox, % new |
 _________________
 |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Sun Jul 06, 2008 10:39 pm Post subject: |
|
|
That simple? I was trying to use.
| Code: | | new .= %grid% "," a_loopfield "`n" |
Thanks allot. |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Sun Jul 06, 2008 11:07 pm Post subject: |
|
|
One problem. This gives me a blank server at the end of the list.
Like this.
grid1,server1,
grid1,server2,
grid1,server3,
grid1,,
grid2,server88,
grid2,server89,
grid2,server90,
grid2,,
Her is my code.
| Code: | GuiControlGet,servers,,Edit1,
loop, parse, servers, `n, `r
newservers .= "`n" grid "," a_loopfield "," |
How can I get it to ignore a blank line? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6084
|
Posted: Mon Jul 07, 2008 6:17 am Post subject: |
|
|
| Code: | GuiControlGet,servers,,Edit1,
loop, parse, servers, `n, `r
newservers .= (( A_Index = 1 ) ? "" : "`n" ) grid "," a_loopfield "," |
_________________
 |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Mon Jul 07, 2008 2:36 pm Post subject: |
|
|
That didn't work. It isn't omitting the blank line at the end of the list. I have to leave a carriage return after every entry. That is how the scanner that I am using works.
My list looks like this.
server1
server2
server3
--->this is a blank line<---
I still get this.
grid1,server1,
grid1,server2,
grid1,server3,
grid1,, |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6084
|
Posted: Mon Jul 07, 2008 5:59 pm Post subject: |
|
|
| Code: | GuiControlGet,servers,,Edit1,
loop, parse, servers, `n, `r
{
ifequal,a_loopfield,, continue
newservers .= (( A_Index = 1 ) ? "" : "`n" ) grid "," a_loopfield ","
} |
 _________________
 |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Mon Jul 07, 2008 10:21 pm Post subject: |
|
|
| That's it.. Thanks so much. |
|
| Back to top |
|
 |
Hedonist
Joined: 24 Jan 2005 Posts: 34
|
Posted: Tue Jul 08, 2008 11:37 pm Post subject: |
|
|
SKAN,
That worked real well in Windows XP, but I am writing this for Windows CE. I get some real strange results when I run it in CE. Here is the link if you want to know more.
http://www.autohotkey.com/forum/viewtopic.php?p=206478#206478
Is there any other way you can think of retrieving and rearranging the data? |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6084
|
Posted: Wed Jul 09, 2008 5:57 am Post subject: |
|
|
| Code: | GuiControlGet,servers,,Edit1,
FileAppend, %servers%, servers.txt |
Jay, can you upload the list, servers.txt ? _________________
 |
|
| 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
|