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 

Help with Arrays pls.

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





PostPosted: Tue Jul 01, 2008 2:38 pm    Post subject: Help with Arrays pls. Reply with quote

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





PostPosted: Tue Jul 01, 2008 2:41 pm    Post subject: Reply with quote

StringSplit
Back to top
erratiC
Guest





PostPosted: Tue Jul 01, 2008 2:43 pm    Post subject: Help with Arrays pls. Reply with quote

And there is Stringsplit right there at the top of the help file Embarassed

Thx Bobo
Back to top
erratiC
Guest





PostPosted: Tue Jul 01, 2008 3:30 pm    Post subject: Re: Help with Arrays pls. Reply with quote

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

PostPosted: Tue Jul 01, 2008 4:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
erratiC
Guest





PostPosted: Wed Jul 02, 2008 10:59 am    Post subject: Reply with quote

Thx tic, u've given me a nice base.

Appreciate it.
Back to top
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