Newbie: find, search command

D.Rothe drothe at optusnet.com.au
Fri Dec 17 17:20:24 EST 2004


Thanx for all the help! The following method was spot on, as for the cr showing a blank line 
at the end of the field I simply used "filter theField without empty".

on mouseUp
do FindData(tString, tData)
end mouseUp

function FindData pStringToFind, pDataToSearch
repeat for each line tLine in pDataToSearch
if pStringToFind is in tLine then put tLine & cr after tFoundData
end repeat
put tFoundData into fld "List"
filter fld "List" without empty
end FindData

D.Rothe

> Message: 1
> Date: Fri, 17 Dec 2004 10:12:17 -0500
> From: "Frank D. Engel, Jr." <fde101 at fjrhome.net>
> Subject: Re: Newbie: find, search command
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <0A93CC3B-503E-11D9-8A4C-0050E410655F at fjrhome.net>
> Content-Type: text/plain; charset=US-ASCII; format=flowed

> Yes, but a cr at the end will show a blank line at the end of a field.  
> Remember that list boxes are fields, and the selectable lines are lines 
> of text from the field.  Since you can hit return/enter and add a blank 
> line at the end of the field and have it displayed, you will also see a 
> blank line at the end of a list box.
> 
> The original poster specifically stated that he wished to display these 
> results in a list box (which is a field), so this is definitely an 
> issue for him.  Trust me, it took me a while to work this one out 
> myself, and I've been using something similar quite heavily (although I 
> let PostgreSQL do most of my sorts and searches for me -- I just format 
> the results...)
> 
> On Dec 16, 2004, at 9:43 PM, J. Landman Gay wrote:
> 
> > On 12/16/04 5:42 PM, Frank D. Engel, Jr. wrote:
> >
> >> Except that you need to delete the last "cr" before putting it into 
> >> the list, or you will have a blank line at the bottom; just add one 
> >> line to the code:
> >>> function FindData pStringToFind, pDataToSearch
> >>>   repeat for each line tLine in pDataToSearch
> >>>      if pStringToFind is in tLine then put tLine &cr after tFoundData
> >>>   end repeat
> >>   delete the last char of tFoundData
> >>>   return tFoundData
> >>> end FindData
> >
> > Sometimes, but it depends on what you're doing. Revolution is 
> > forgiving enough that a lot of the time it doesn't matter. For 
> > example, "the number of lines" will return the same number whether the 
> > carriage return is at the end or not.
> >
> > This has come up before, and it isn't a bug, it's a feature. Commas 
> > work the same way.
> >
> >
> >> On Dec 16, 2004, at 6:32 PM, Richard Gaskin wrote:
> >>> D.Rothe wrote:
> >>>
> >>>> Hi,
> >>>> I have a tab delimited list I want to be able to search, say I have 
> >>>> a list of names for example;
> >>>> Father Xmas    Is Drunk
> >>>> New Years    Is after Xmas
> >>>> Rudolph    The Reindeer
> >>>> Merry Xmas    To all
> >>>> I want to search for ALL instances of Xmas and display the whole 
> >>>> matching line of each found in a list field.
> >>>> So far I can get it to display the first line only ( Father Xmas    
> >>>> Is Drunk) ! Any help would appreciated!!! I have checked the 
> >>>> tutorials for help but couldn't find what I was looking for,
> >>>> is there an example stack or notes anyone may know of?
> >>>
> >>>
> >>> For short lists (<50,000 lines) you may be pleasantly surprised by 
> >>> the speed of what might look like clunkly Transcript:
> >>>
> >>>
> >>> function FindData pStringToFind, pDataToSearch
> >>>   repeat for each line tLine in pDataToSearch
> >>>      if pStringToFind is in tLine then put tLine &cr after tFoundData
> >>>   end repeat
> >>>   return tFoundData
> >>> end FindData
> >>>
> >>>
> >>> You can call it simply enough:
> >>>
> >>> on mouseUp
> >>>   put FindData("Xmas", fld "stuff")
> >>> end mouseUp
> >>>
> >>>
> >>> -- 
> >>>  Richard Gaskin
> >>>  Fourth World Media Corporation


More information about the use-livecode mailing list