>>>on mouseUp me
>>>global  gMoveAmt
>>>set myIndex  = 1
>>>repeat while not the mouseDown
>>>setMoveAmt  =  setAt (gMoveAmt, myIndex)
>>>set myIndex  = myIndex +1
>>>if myIndex > 100 then exit  repeat
>>>end repeat
>>>end
>>
>>That's a repeat loop. Not optimum, but better than the first.
>
>May I know where my mistake lies?

Sure. I'm not sure why you're checking for the mouseDown. If that's not 
relevant, this would be a bit faster:

repeat with myIndex = 1 to 100
   setMoveAmt = setAt(gMoveAmt, myIndex)
end repeat

A couple of comments. You do realize that you're building a list, right? 
Actually, that code won't work, because setAt requires 3 parameters--the 
list, the position, and the value. setMoveAmt will contain only TRUE or 
FALSE, the result of the setAt operation. Did you mean to use getAt?


>Is it because I am using globals?
>I  also  notice that the code people hand out here usually uses  p = 
>property to describe ?

properties are specific to a particular instance. For example, if you had 
100 sprites and you wanted to know their position, you would use something 
like this in a behavior:

property pMyLocH

on beginSprite
   pMyLocH = sprite(me.spriteNum).locH
end

on getMyLocH
   return pMyLocH
end

In that example, you have one behavior, but 100 different values for 
pMyLocH--one for each sprite.

Globals, on the other hand, are not inherently bad unless used to excess. 
Just remember that their value will be the same no matter where you are.

>>>1.      What is the meaning of [:] ?  I notice it is used in
>>>getPropertyDescriptionLists.
>>
>>That declares an empty property list.
>
>The purpose of declaring an  empty property list is to add items to the 
>list.  You didn't do that, you just defined  it immediately?

It's always best to initialize variables. The [:] ensures that the variable 
is a property list, and that it is empty. If you try to add a property and 
value to an uninitialized variable, it will return an error because it's 
not a property list.

>So, I need to optimize lingo performance by writing 'better'  code?

The same answer as when you asked before--sometimes yes, sometimes it 
doesn't make a difference. Of course it's always better to have optimized 
code, but it's often not worth spending a lot of programming time to 
squeeze every last millisecond out of your code. Sometimes it is--80% of 
your program's time will be spent in 20% of its code. That 20% is what 
needs to be optimized.

>Aren't you a killjoy?

My specialty.

>A nested loop is written in this way: First there is a loop, then you have
>another loop within this loop. Normally, you should exit the inner loop
>first then you exit the outer loop. Is this correct?

Pretty much. The inner loop runs *within* the outer loop. Think of it this 
way. I ask you to go to ten different grocery stores and get 5 items at 
each store. The grocery stores are the outer loop, and the items are the 
inner loop.

>Use it as often as possible  and frustrate / disturb / confound a certain 
>person by the name of  Kerry Thompson less.

Gotta watch out for him. He's mean. His Lingo code really bytes.

Cordially,

Kerry Thompson


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]

Reply via email to