 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Mon Dec 14, 2009 11:30 pm Post subject: Does TF_Find function as described or I misinterpreted |
|
|
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?
Thanks, for any help you can provide.
Have a Merry Christmas and Great New Year. [/code] _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Tue Dec 15, 2009 7:18 am Post subject: |
|
|
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 Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Tue Dec 15, 2009 9:56 pm Post subject: |
|
|
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 ] _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| 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
|