Hello,

First, I'm very happy as I managed to defend my M.A. thesis to an excellent
mark. Second, I'm a bit confused: when do I use variables and when do I use
functions straight ahead?

E.g. I wanted to make a handler that would check for definite members in
definite castLib and then add the results to the list. When I tried to use
this:
------------------------------------------
property pVectorShape

on getPropertyDescriptionList(me)
  vectorShapesList = []
    repeat with j = 1 to the number of members of castLib "Assets"
      if(member(j).type = #vectorShape) then
        vectorShapesList.add(j)
      end if
    end repeat
  descriptionList = [:]
  descriptionList.addProp(#pVectorShape, [#comment:"Which one",
#format:#member, #range:vectorShapesList, #default:1])
  return(descriptionList)
end
------------------------------------------
Director returned a script error (moreover, even a fatal one). But, when I
changed the code a bit to:  (as an inspiration for the below handler I used
a royalty free code by Brian Robbins posted on 2/28/2004 at dirGames-l)
------------------------------------------
property pVectorShape

on getPropertyDescriptionList(me)
  vectorShapesList = []
    repeat with j = 1 to the number of members of castLib "Assets"
      theMember = member(j, i)
      if(theMember.type = #vectorShape) then
        vectorShapesList.add(theName)
      end if
    end repeat
  descriptionList = [:]
  descriptionList.addProp(#pVectorShape, [#comment:"Which one",
#format:#member, #range:vectorShapesList, #default:1])
  return(descriptionList)
end

Worked just fine.
Another example may be considered as follows:
------------------------------------------
property pSprite
property pLocH

on beginSprite(me)
  pSprite = (me.spriteNum)
  pLocH = sprite(pSprite).locH
end

on exitFrame(me)
  distH = (_mouse.mouseH - pLocH)
  put(distH)
end
------------------------------------------
Works just fine though I didn't assign _mouse.mouseH to a separate variable.
This example:
------------------------------------------
property pSprite
property pLocH

on beginSprite(me)
  pSprite = (me.spriteNum)
  pLocH = sprite(pSprite).locH
end

on exitFrame(me)
  theMouseH = _mouse.mouseH
  distH = theMouseH - pLocH
  put(distH)
end
------------------------------------------
Works fine too but it just has that redundant and confusing assignment.

I know, questions like this are really generalizing and presuppose complex
methods of research and experience but still: should I stick to idea to
always use variables instead of "straight" function using or are there sort
of exceptions or rules that I am to stick to?

Thanks in advance

-------------------
Peter Bochan
Associate Assistant
College of Foreign Languages
Chernivtsi National University
Ukraine


[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!]

Reply via email to