Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find text inside existing files
#12
I created a function for this. Will need less code if using in several places.
Function FindItemInTextFile
Code:
Copy      Help
;/
function! $file_ $item

;Finds a line in a text file.
;Returns 1 if found, 0 if not.


str sData.getfile(file_)
if(!sData.len) ret
IStringMap m=CreateStringMap(1|2)
m.AddList(sData "[]")
if(m.Get(item)) ret 1

example
Macro Macro1649
Code:
Copy      Help
str s.getsel

int found=FindItemInTextFile("$desktop$\test\test.txt" s)
if found
,out "found"
else
,out "not found"


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)