Hi Sam

If you have any C++ experience, then think of a property as a C++ member
variable (or in a true OOPish sense, a private member variable) and a
variable in the terms of how variables work in C++ and other languages.
More precisely, a property is constrained to an object, it is the data
storage aspect of the object.  In an OOPs world, an object is a container
that can hold both data and functions (handlers). When working in Lingo, you
have two places where properties can be stored: a behaviour and a
childObject (an instance of a parent script). A variable does not have to be
confined to an object and can exist in any handler type that exists in the
project, it can be transient (local) or global (lasting from the time it is
declared until the end of the project). A property has scope only within the
object and lasts for the length of time that the object exists for, in other
words a property derives its scope from the scope of the object. One might
argue that a behaviour and an object differ, but IMHO,  a behaviour is
simply a specialized object type that MACR has created with specialized
constructors and destructors that are called when the sprite (or frame - a
frame script is simply a behaviour attached to sprite(0))comes into
existence and when the sprite goes out of existance on the score.  An object
on the other hand is created by the programmer and is explicitly
instantiated by the programmer using the on new  handler (although it can be
also instantiated using the rawNew command which bypasses the constructor so
to speak), and is destroyed (garbage collected) when the last reference to
the object is removed.  All properties of a behaviour and or an object are
automatically created when the behaviour or object is instantiated (they may
be set to void if no default values are given) but they are in existence.  A
variable on the other hand comes into existence when first used and either
stay in existence until the end of the project (globals) or until the end of
the handler they are used in (locals). Properties as mentioned above come
into existance when the object/behaviour comes in to existence and remain
until the object/behaviour is destroyed, regardless of whether or not they
contain "valid" information. An object could be instantiated into a local
variable, used within a handler and destroyed at the end of the handler or
they could be birthed into a global and exist for the remaining duration of
the movie. A property can also be the container that is used to hold another
object reference etc... thus one object, birthed into a global could
theoretically become a major container that is used to hold and track
thousands of accessory objects that can be instantiated and destroyed at
various points throughout the movie. Thus to come back to your original
question, can you set global scope for a property, yes and no, a property
has the scope of the object it is in and as such its information can only be
stored for the length of time that the object of which it is a data storage
container, exists in RAM.  If you have a global object, then you will have,
in theory, a global property within that global object. Each property is
unique to the instance of the object that it is birthed in, thus if you have
a behaviour that is instantiated 5000 times, then each instance will have
its own unique data members (properties) within itself. Thus the data of a
property within a behaviour or object instance is not affected by what is in
the instance of the same named property in another instance of the same
behaviour script or parent script.

Have I confused the heck out of you yet??

Sincerely

Mark

--------------------------------------------
Mark R. Jonkman
Mark R. Jonkman Consulting
ADDRESS: 20 Windermere Crt., Guelph, ON, CANADA N1E 3L4
PHONE: 519-837-8509
EMAIL: [EMAIL PROTECTED]
--------------------------------------------
>
> What is the exact difference between a property and a (standard)
> variable -
> can you set global scope for a property?
>
> Cheers,
>
> Sam and the Elektonika team.


[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