AutoHotkey Community

It is currently May 27th, 2012, 8:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: January 6th, 2007, 1:20 am 
Offline

Joined: December 27th, 2006, 11:30 pm
Posts: 29
first off, how does file-read loop work and how can I use it in the following situation?

I would like to have the script read each line (unknown number of lines) and input each one as a separate variable using file-read loop and stringsplit (or parse) and then input this data into a listbox so the user can select the numbers (in this case serial numbers) and then click a button to input the data into an edit field.

Code:
loop, read, well_serial_numbers.txt
{
    stringsplit, wellserial, ?????
}
Gui, 2: Add, Listbox, x16 y62 w100 h300 0x8 gnumberlistview, %1%|%2%|%3%|[etc. up to 20 or so]


So far I have gotten it to work with FileReadLine but then I would have to know how many lines there were. Also is there a way to input all of the lines as variables into the list box without specifying the variables as %1%|%2%|[etc]?

Here's a slightly shortened version:
Code:
Document_Image_Search:
ArrayCount = 0
Loop, Read, well_serial_numbers.txt
{
    ArrayCount += 1
    Array%ArrayCount% := A_LoopReadLine
}
FileReadLine, 1, well_serial_numbers.txt, 1
FileReadLine, 2, well_serial_numbers.txt, 2
FileReadLine, 3, well_serial_numbers.txt, 3
FileReadLine, 4, well_serial_numbers.txt, 4
FileReadLine, 5, well_serial_numbers.txt, 5
Gui, 2: Add, GroupBox, x6 y10 w220 h360 , Wells
Gui, 2: Add, Listbox, x16 y62 w100 h300 0x8 gnumberlistview, %1%|%2%|%3%|%4%|%5%
Gui, 2: Add, Button, x116 y30 w100 h40 gsearchbutton1, Search
Gui, 2: Add, Edit, x116 y320 w100 h20 , Add Serial Number
Gui, 2: Add, Button, x116 y340 w90 h20 AddNumberbutton, Add Number
Gui, 2: Add, Button, x260 y90 w110 h30 Logsbutton, Logs
Gui, 2: Add, Button, x260 y130 w110 h30 gWellFilesbutton, Well Files
Gui, 2: Add, GroupBox, x240 y70 w150 h100 , Type of Document
Gui, 2: Add, Button, x260 y310 w110 h40 gNewSearchbutton, New Search
Gui, 2: Add, Text, x116 y280 w100 h30 , Find
Gui, 2: Add, Button, x116 y100 w100 h30 gDeletebutton, Delete
Gui, 2: Add, GroupBox, x240 y200 w150 h80 , Search
Gui, 2: Add, Edit, x250 y230 w44 h0 , Search
Gui, 2: Add, Button, x260 y250 w110 h20 gsearchbutton2, Search
Gui, 2: Add, Edit, x260 y220 w110 h20 , Individual Search
Gui, 2: Add, Button, x246 y12 w150 h30 , Document Image Search Site
Gui, 2: Add, Text, x16 y32 w100 h20 , Number of Wells: %ArrayCount%
Gui, 2: Show, x170 y110 h377 w402, Document Image Search
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2007, 6:12 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
I still haven't learned alot about listboxes, but I can definately help with File reading loops.

here is a sample text file: test.txt
Code:
Plymouth MA 02360
Seattle WA 98107
Kent WA 98032
Honolulu HI 96818


And here is something to do with it

Code:
Zipcodes =
Loop, Read, test.txt
{
StringSplit, address, A_LoopReadLine, %A_space%
MsgBox, Line, %A_index% is %A_LoopReadLine% which splits to %Address1%, %Address2%, %Address3%
Zipcodes = %Zipcodes%|%address3%
}

Gui, 2: Add, Listbox, x16 y62 w100 h300 0x8 gnumberlistview, %Zipcodes%

Or, you can use LV_Add or LV_modify

Code:
Gui,  Add, Listbox, x16 y62 w100 h300 0x8 gnumberlistview,

Loop, Read, test.txt
{
StringSplit, address, A_LoopReadLine, %A_space%
MsgBox, Line, %A_index% is %A_LoopReadLine% which splits to %Address1%, %Address2%, %Address3%
;Insert an LV_add command here
}

Gui, Show

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 6th, 2007, 8:01 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
Hi, try this code:

Code:
Document_Image_Search:
FileRead, Array, well_serial_numbers.txt
StringReplace, Array, Array, `r`n, |, UseErrorLevel
ArrayCount := ErrorLevel
StringRight, Last, Array, 1
if (Last <> "|")
  ArrayCount++
Gui, 2: Add, GroupBox, x6 y10 w220 h360 , Wells
Gui, 2: Add, Listbox, x16 y62 w100 h300 0x8 gnumberlistview, %Array%
Gui, 2: Add, Button, x116 y30 w100 h40 gsearchbutton1, Search
Gui, 2: Add, Edit, x116 y320 w100 h20 , Add Serial Number
Gui, 2: Add, Button, x116 y340 w90 h20 AddNumberbutton, Add Number
Gui, 2: Add, Button, x260 y90 w110 h30 Logsbutton, Logs
Gui, 2: Add, Button, x260 y130 w110 h30 gWellFilesbutton, Well Files
Gui, 2: Add, GroupBox, x240 y70 w150 h100 , Type of Document
Gui, 2: Add, Button, x260 y310 w110 h40 gNewSearchbutton, New Search
Gui, 2: Add, Text, x116 y280 w100 h30 , Find
Gui, 2: Add, Button, x116 y100 w100 h30 gDeletebutton, Delete
Gui, 2: Add, GroupBox, x240 y200 w150 h80 , Search
Gui, 2: Add, Edit, x250 y230 w44 h0 , Search
Gui, 2: Add, Button, x260 y250 w110 h20 gsearchbutton2, Search
Gui, 2: Add, Edit, x260 y220 w110 h20 , Individual Search
Gui, 2: Add, Button, x246 y12 w150 h30 , Document Image Search Site
Gui, 2: Add, Text, x16 y32 w100 h20 , Number of Wells: %ArrayCount%
Gui, 2: Show, x170 y110 h377 w402, Document Image Search
return


Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2007, 4:55 pm 
thank you, both of you. now how would I copy the numbers in the listbox that are highlighted (and find out how many were copied) into another file? I can do it with arrays right?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2007, 4:55 pm 
Offline

Joined: December 27th, 2006, 11:30 pm
Posts: 29
Anonymous wrote:
thank you, both of you. now how would I copy the numbers in the listbox that are highlighted (and find out how many were copied) into another file? I can do it with arrays right?


sorry, forgot to login


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2007, 9:09 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
hi Phe0n1x,

change one line

Code:
Gui, 2: Add, Listbox, x16 y62 w100 h300 0x8 vSelected gnumberlistview, %Array%


and add following lines
Code:
searchbutton1:
gui, 2: submit
StringReplace, Selected, Selected, |, `n, All
FileDelete, well_serial_numbers_out.txt
FileAppend, %Selected%`n, well_serial_numbers_out.txt
return

and you will find the selected numbers in a new file

Hubert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2007, 6:14 pm 
Offline

Joined: December 27th, 2006, 11:30 pm
Posts: 29
thank you, now I have all I need


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2009, 8:21 am 
Offline

Joined: May 31st, 2008, 3:22 pm
Posts: 47
mb im stupid but all thts codes > Target label does not exist

fck i just need make multi search in spec chosen

. CheckListBox

. SeekList.txt

. GHK, Add cliboard to SeekList.txt

for example when need seek in many (5~10) (my choosen) sites

or for example sometime need, on one site (mobygames) with specific parameters.

i guess simply create in delphi, that primitive (SmartGui? )) noway that sux!


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, migz99 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