Re: lingo-l Just out of curiosity (repeat loop)

2002-09-25 Thread roy crisman


I'd also be careful of:

repeat with i = 1 to thisList.count

because this is depending upon thisList to not change size, and is actually 
slower than:

iMax = thisList.count
repeat with i = 1 to iMax

because you're not accessing the .count of the list multiple times.


roymeo

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]



Re: lingo-l Just out of curiosity (repeat loop)

2002-09-22 Thread Mark A. Boyd

At 21:18 2002-09-21, Colin Holgate wrote:
on repeatList aList
   repeat with i in aList
 put aList.getPos(i)
   end repeat
end

Buzz's hidden counter will work, but this one may fail. What happens if a 
later entry in the list is a repeat of an earlier entry?

As I said in the sentence immediately preceding that code, Of course, this 
will not work for lists with duplicate entries. Immediately following that 
code was a demonstration of what happens. To put it in words, getPos() will 
return the only first occurrence of the parameter supplied.

Following that was a hidden counter snippet that works just as Buzz's 
does, though it was initiated as 1 and incremented at the end of the repeat 
rather than at the start. He beat me by two minutes.


--
Mark A. Boyd
Keep-On-Learnin' :)

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]



Re: lingo-l Just out of curiosity (repeat loop)

2002-09-22 Thread Colin Holgate

As I said in the sentence immediately preceding that code, Of 
course, this will not work for lists with duplicate entries. 
Immediately following that code was a demonstration of what happens. 
To put it in words, getPos() will return the only first occurrence 
of the parameter supplied.

You know Malk, I could do with reading things more carefully!



(ps. the Malk part was a joke)

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]



lingo-l Just out of curiosity (repeat loop)

2002-09-21 Thread Andreas Gaunitz P11

In some cases it's convenient to use 'repeat with anItem in aList', 
to roll through the entries of a list. However, pretty often I 
realize I need a counter for one reason or other, so i resort to use 
'repeat with itemCounter = 1 to aList.count'.

I have often wondered if there's a hidden counter somewhere that 
Director uses when counting throough the items using 'repeat with 
anItem in aList'? If so, can I check the value of that counter and 
use it?

No big deal, just curious.

-A.



[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]



Re: lingo-l Just out of curiosity (repeat loop)

2002-09-21 Thread Buzz Kettles

At 5:08 PM +0200 9/21/02, you wrote:
In some cases it's convenient to use 'repeat with anItem in aList', 
to roll through the entries of a list. However, pretty often I 
realize I need a counter for one reason or other, so i resort to use 
'repeat with itemCounter = 1 to aList.count'.

I have often wondered if there's a hidden counter somewhere that 
Director uses when counting throough the items using 'repeat with 
anItem in aList'? If so, can I check the value of that counter and 
use it?

No big deal, just curious.

yes, there's a hidden counter.

 if you want it, create it!

hiddenCounter = 0
repeat with anItem in aList
hiddenCounter = hiddenCounter + 1
put hiddenCounter
end


hth

-Buzz


-A.



[To remove yourself from this list, or to change to digest mode, go 
to http://www.penworks.com/lingo-l.cgi  To post messages to the 
list, email [EMAIL PROTECTED]  (Problems, email 
[EMAIL PROTECTED]). Lingo-L is for learning and helping with 
programming Lingo.  Thanks!]

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]



Re: lingo-l Just out of curiosity (repeat loop)

2002-09-21 Thread Colin Holgate

on repeatList aList
   repeat with i in aList
 put aList.getPos(i)
   end repeat
end

Buzz's hidden counter will work, but this one may fail. What happens 
if a later entry in the list is a repeat of an earlier entry?

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]