"repeat for each" in reverse order ?

Dennis Brown see3d at writeme.com
Tue Jun 28 10:59:32 EDT 2005


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

On Jun 28, 2005, at 8:08 AM, Robert Brenstein wrote:

>> When it comes to the 'each element' form, you are right that it is  
>> ambiguous at first glance, but would seem reasonable that sorting  
>> applies to the elements themselves since keys are not explicitly  
>> entering the picture. To get sorting on keys we would need to say
>>
>>   repeat for each line tKey in the keys of myArray ascending
>>
>>
>
> Oops. My thinking went a bit astray. What you are talking about is  
> more like
>
>   repeat for each element foo of fooArray ascending by key of each
>
> Robert
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list