AutoHotkey Community

It is currently May 27th, 2012, 12:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: December 15th, 2009, 12:30 am 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Hi again, Hugov

Yet another question about TF.ahk Lib

Is this misinterpreting the way this function works?

Code:
F = ScripletLibTitles.txt
Rows := LV_GetCount()
FoundRows := TF_Find(F, 1, Rows, SearchText, 0, 0)


Accroding to the Tf Tutorial, the Syntax for TF_Find is:
TF_Find(Text, StartLine = 1, EndLine = 0, SearchText = "", ReturnFirst = 1, ReturnText = 0)

In my script, I'm using ReturnFirst = 0 return multiple lines
and ReturnText = 0 return line numbers only

Does this mean?
1. the result of the search returns the total lines containing the SearchText OR
2. each line number containing the SearchText result.

When I run the script, if the SearchText is Blank.
It returns each line number separated by comma's.
for the total LV_GetCount value.

If the SearchText contains a String,
It returns the total lines containing the SearchText.

Is this the way it is supposed to work?

I'm trying to find each line number containing the search result
so I can save those line number values and use another routine to go to
each of the line numbers containing the SearchText like this.
Code:
Loop, parse, FoundRows, `,
{
    RN := %A_LoopField%   ; Rn = row number
    LV_GetText(SearchText, RN, 1)
    LV_Modify(RN, "Focus")  ; Focus on Row with Search Text
    LV_Modify(RN, "Select")  ; Selects Row with Search Text
}

Can I use TF_Find to perform this method? If not,
can I modifiy TF_Find for my situation to get each line number?

Or is there another method for getting the line number values? :roll:

Thanks, for any help you can provide.

Have a Merry Christmas and Great New Year. :lol:[/code]

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 8:18 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
An example works best I guess:
Code:
list=
(
Line 1 this is a test hello
Line 2 this is a test hi
Line 3 this is a test how
Line 4 this is a test are
Line 5 this is a test hello
Line 6 this is a test doing
)
SearchText=hello

MsgBox % TF_Find(list, 1, 0, SearchText, 1, 0) ; result: 1
MsgBox % TF_Find(list, 1, 0, SearchText, 0, 0) ; result: 1,5
MsgBox % TF_Find(list, 1, 0, SearchText, 1, 1) ; result: "Line 1 this is a test hello"
MsgBox % TF_Find(list, 1, 0, SearchText, 0, 1) ; result: "Line 1 this is a test hello`nLine 5 this is a test hello"
MsgBox % TF_Find(list, 1, 0, SearchText, 0, 2) ; result: "1: Line 1 this is a test hello`n5: Line 5 this is a test hello"
You don't need "Rows" you can simply pass on 0 if you want to find/process all lines in a file or variable.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 10:56 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Hi Hugov,

Thanks for the Clear, Concise answers :!:

When I put the TF_Find Parameters in a Matrix, I't's even Clearer.
Quote:
TF_Find Paramenters
--------------------
ReturnFirst = 0 return multiple lines
ReturnFirst = 1 return first line only

ReturnText = 0 return line numbers only
ReturnText = 1 return entire line (text). This simulates a basic grep feature
ReturnText = 2 return line numbers + entire line (text). This simulates a basic grep feature
------------------------
TF_Find Parameter Matrix
------------------------
0|0 - 0, 0 returns ALL results by LINE number [1,5]
0|1 - 0, 1 returns All Lines of TEXT containing SearchText
1|0 - 1, 0 returns ONLY 1 Line# [Line1] as result
1|1 - 1, 1 returns ONLY 1 Line#'s TEXT
1|2 - 1, 2 returns ALL Line#'s & Text containing SearchText

Have a Merry Christmas & Great New Year :lol: ]

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google [Bot], iDrug, Leef_me, Ohnitiel, rjgatito, Yahoo [Bot] and 22 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