AutoHotkey Community

It is currently May 27th, 2012, 9:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Questions about LOOP
PostPosted: November 29th, 2011, 11:40 pm 
Offline

Joined: November 10th, 2005, 11:26 pm
Posts: 169
Location: Texas
I got a question for a script I'm working on.

I'm doing a FileReadLine in my script, but I don't want to read every line.
Can I:
A) increment the loop count by say 5, so I could just read lines 5, 10, 15, etc.?
or
B) mathematically change A_INDEX's value and assign it the next increment ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2011, 11:53 pm 
Offline

Joined: August 7th, 2011, 1:23 pm
Posts: 754
Code:
line := 0
loop
{   
   line +=5   
   FileReadLine, OutputVar, Filename, %line%
   if ErrorLevel
        break
   msgbox %OutputVar%
}   


_________________
Win7 - Firefox 10.0.2 - AHK_L 1.1.07.00
Please bear with me and my English which is so bad at times that even I don't understand myself


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2011, 11:54 pm 
Offline
User avatar

Joined: September 1st, 2011, 8:21 pm
Posts: 368
Location: California
Code:
Loop
{
   lineNo := A_Index * 5
   FileReadLine, line, %A_temp%\msc.txt, %lineNo%
   if ErrorLevel
      break

   MsgBox, 4, , Line #%lineNo% is "%line%".  Continue?
   IfMsgBox, No
      return

}
MsgBox, The end of the file has been reached or there was a problem.
return


beaten by Odlanir


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2011, 9:44 am 
Possibly of interest:
http://www.autohotkey.net/~hugov/tf-lib ... _ReadLines can return the specified lines, can be used to read sections of a file or variable, also using incremental values e.g. every 5th line.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2011, 2:14 pm 
Offline

Joined: November 10th, 2005, 11:26 pm
Posts: 169
Location: Texas
Thanks to all that replied

Odlanir... your solution seems to me to work the best. Thanks

I should have figured this out, but hand AHK'd in awhile and so my mind just is kinda numb :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher and 67 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group