search text result

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

search text result

Post by gepponline » Wed Mar 18, 2015 10:38 am

Hi!
I have to search in a text if there is a certain string.
In details I have to check if a file is in a folder.
So i get the list of files with "the files"

Now searching the web i found the "find" command, but it seems that it draw a box around a text instead of answer if is it found or not.

How should i do to know if the text is present or not?


OT: I found in the dictionary that every command is well explained but not the results.
You know, you can find for every command what it does but not where it place its "result".
I think that more than Syntax, summary and examples, every command should have an "OUTPUT" section to tell the user what and where does the command/function give back.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: search text result

Post by magice » Wed Mar 18, 2015 12:47 pm

Look up foundText and foundLine. :D

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: search text result

Post by gepponline » Wed Mar 18, 2015 1:44 pm

beeing a search of a file in a folder, I'm searching in "the files" is correct to write something like this?

Code: Select all

 set the defaultFolder to specialFolderPath("documents")
   put the files into tFileList
   find "censimentofiliere.txt" in tFileList
   if the foundText is "censimentofiliere.txt" then   

Klaus
Posts: 11009
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: search text result

Post by Klaus » Wed Mar 18, 2015 1:46 pm

Hi Geppo,

since the FIND command is intended to give a visual feedbak (square around the found word/chunk)
this should be used for finding things inside of fields in LC.

When searching for strings in text files or even fielnames in file listings, using "lineoffset" is much more efficient!

Code: Select all

set the defaultFolder to specialFolderPath("documents")
put the files into tFileList
put lineoffset("censimentofiliere.txt",tFileList) into tFoundLine
if tFoundLine = 0 then
  ## not found
else
  file is existent in listing
end if

Best

Klaus

gepponline
Posts: 91
Joined: Tue Sep 03, 2013 1:53 pm

Re: search text result

Post by gepponline » Wed Mar 18, 2015 2:34 pm

...Klaus..my personal trainer :)

thank you very very much :)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”