A chunking mystery

Scott Rossi scott at tactilemedia.com
Fri Mar 14 00:09:06 EDT 2008


Recently, David Coker wrote:

> I have a handler built that does nothing more than checking for a zero
> in a specific item located in a scrolling text field and if found,
> deletes the entire line. It seemed to work flawlessly with all of the
> test files that I had chosen to work with while building the app.
> ... 
>   repeat for each line thisLine in tSource
>     if item 2 of line 1 of tSource = "0" then
>       delete line 1 of tSource
>     end if
>   end repeat

I'm not sure exactly what you're trying to test, but your repeat loop seems
a little off. Perhaps you intended something like this (assuming tSource is
a variable containing the text of a field):

   repeat with N = number of lines of tSource down to 1
     if item 2 of line N of tSource = "0" then delete line N of tSource
   end repeat

Another option (assemble text in a new variable):

   repeat for each line thisLine in tSource
     if item 2 of thisLine <> "0" then put thisLine & cr after tFilteredText
   end repeat
   delete last char of tFilteredText
   -- do something with tFilteredText

Each of the above should result in removal of any lines in the source text
that contain 0 in item 2 of the line.  Another thing to check is that you're
using the appropriate itemDelimiter (comma is the default, but you can set
the itemDelimiter to another character).

If the above is not what you're after, you might need to explain what is
actually stored in tSource.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design





More information about the Use-livecode mailing list