"repeat for each" in reverse order ?

Buster wouter.abraham at scarlet.be
Wed Jun 29 19:16:46 EDT 2005


Hi Dennis,

  I'm just curious, but what is wrong with itemOffset?

Greetings,
Wouter


> Re: "repeat for each" in reverse order ?
> Dennis Brown
> Tue, 28 Jun 2005 07:59:41 -0700
>
> What I would like to see is a way to access the next or previous  
> "element" in a list independent of the repeat structure. We have  
> something similar in the offset function --offset  
> (findString,searchString,skipChars). The key is to have a concept  
> for a pointer of sorts. The pointer in the offset function is the  
> skipChars parameter. You could just about simulate this capability  
> using the offset function (not tested):
>
> global gStringName,gStringNamePtr
> function nextItemStringName --don't want to pass the actual strings
>     get offset(itemDel(), gStringName, gStringNamePtr)
>     if it = 0 then --delimiter not found, must be end of string
> return char gStringNamePtr to -1 of gStringName --last item in the  
> string, or empty
>     else
> return char gStringNamePtr to gStringNamePtr +it-1 of gStringName -- 
> grab the next item put it+1 into gStringNamePtr --advance the  
> pointer to after the delimiter
>     end if
> end nextItemStringName
>
> Of course this way of doing it is not so general, a bit awkward,  
> and the function calls would kill a lot of the potential speed.  
> That is why a built-in function would be much better. Perhaps a  
> syntax something like this:
>
> nextItem(stringName,charOffsetVar)
>
> The variable name specified for the charOffsetVar would have the  
> pointer that gets modified.
>
> You could also make it a command something like:
>
> nextThing stringName with charOffsetVar by item
>
> Having sequential access methods like this would allow a much  
> greater freedom to process one or more lists at the same time  
> without suffering the usual speed penalties.
>
> Dennis




More information about the use-livecode mailing list