 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
erratiC Guest
|
Posted: Tue Jul 01, 2008 2:38 pm Post subject: Help with Arrays pls. |
|
|
| Quote: | ;Write to the array:
ArrayCount = 0
Loop, Read, C:\Guest List.txt ; This loop retrieves each line from the file, one at a time.
{
ArrayCount += 1 ; Keep track of how many items are in the array.
Array%ArrayCount% := A_LoopReadLine ; Store this line in the next array element.
}
; Read from the array:
Loop %ArrayCount%
{
; The following line uses the := operator to retrieve an array element:
element := Array%A_Index% ; A_Index is a built-in variable.
; Alternatively, you could use the "% " prefix to make MsgBox or some other command expression-capable:
MsgBox % "Element number " . A_Index . " is " . Array%A_Index%
} |
Hi all, the help file example is awesome if u just want 1 field but what if i want more than 1 piece of info taken from a line? For eg,
Username, Password
How would i go abt doing this?
Thx for ur help. |
|
| Back to top |
|
 |
BoBo² Guest
|
Posted: Tue Jul 01, 2008 2:41 pm Post subject: |
|
|
| StringSplit |
|
| Back to top |
|
 |
erratiC Guest
|
Posted: Tue Jul 01, 2008 2:43 pm Post subject: Help with Arrays pls. |
|
|
And there is Stringsplit right there at the top of the help file
Thx Bobo |
|
| Back to top |
|
 |
erratiC Guest
|
Posted: Tue Jul 01, 2008 3:30 pm Post subject: Re: Help with Arrays pls. |
|
|
| erratiC wrote: | | Quote: | ;Write to the array:
ArrayCount = 0
Loop, Read, C:\Guest List.txt ; This loop retrieves each line from the file, one at a time.
{
ArrayCount += 1 ; Keep track of how many items are in the array.
Array%ArrayCount% := A_LoopReadLine ; Store this line in the next array element.
}
; Read from the array:
Loop %ArrayCount%
{
; The following line uses the := operator to retrieve an array element:
element := Array%A_Index% ; A_Index is a built-in variable.
; Alternatively, you could use the "% " prefix to make MsgBox or some other command expression-capable:
MsgBox % "Element number " . A_Index . " is " . Array%A_Index%
} |
Hi all, the help file example is awesome if u just want 1 field but what if i want more than 1 piece of info taken from a line? For eg,
Username, Password
How would i go abt doing this?
Thx for ur help. |
Ok, i know that i have to join stringsplit and the above example... but how do i read more than 1 piece of info from a line and still carry on reading from the next line?
Eg.
Username, Password
Username2, Password2
Again, thx for ur help. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1353
|
Posted: Tue Jul 01, 2008 4:52 pm Post subject: |
|
|
well erratiC you could perform 2 loop, parses:
| Code: | Str = Line1_Hello,Line1_What,Line1_Bye`nLine2_Hello,Line2_What,Line3_bye
Loop, Parse, Str, `n
{
Loop, Parse, A_LoopField, `,
MsgBox, %A_LoopField%
} |
|
|
| Back to top |
|
 |
erratiC Guest
|
Posted: Wed Jul 02, 2008 10:59 am Post subject: |
|
|
Thx tic, u've given me a nice base.
Appreciate it. |
|
| 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
|