Your array (list) functions work fine, but you are missing a key 
concept of object oriented programming.  The key is that objects are 
all about data and code working together.  Your "Array Parent" has a 
fine set of handlers, but that's all it is, a set of handlers.  Given 
what you have shown, there is no reason to create an object since 
these handlers operate only on the data passed it.  They don't share 
any data.

If you really want to do this in an OOP way, you want to have the 
object maintain and operate on the data.  For example, when you want 
to be able to manipulate items in an array (or a one dimensional 
list), you could do this:

-- Whereever you want to create your array:
global array

myList = [1,2,"a",6,"g"]
array = new(script "Array Parent", myList)

And the object would look like this:

property pMyList  -- property which is my list

on new me, startingList
    pMyList = startingList
    return me
end

on _shift me
    myValue = pMyList[1]
    deleteAt(pMyList, 1)
    return myValue
end

on _unshift me, myValue
    addAt(pMyList, 1)
end

on _push me, myValue
    append(pMyList, myValue
end

etc.

This also allows you to have multiple arrays:

global array1
global array2

array1 = new(script "Array parent", [1,2,3,4,5])
array2 = new(script "Array parent", ["A", "B", "C", "D", "E", "F"]

Again, the idea here is that the data is kept _inside_ the object - 
or another way to say this is that the object "owns" the data.  You 
could certainly add two more "accessor" routines to get and set the 
data for the array:

on setList newList
    pMyList = newList
end

on getList
    return pMyList
end

For more about this, feel free to check out my EBook on OOP in Lingo at:

   http://www.furrypants.com/loope

Especially in chapter 5 where I talk about using objects to model a 
two dimensional array.

Irv

At 11:59 PM -0400 4/30/01, b_douglas wrote:
>Hey all,
>
>I needed an easier way to deal with lists so I made these functions
>so far it only deals with linear lists but I am working on propertyLists
>
>so in your movie script:
>on prepareMovie
>   global array
>   array = new (script"Array Parent")
>end
>
>
>
>Then in your movie you can use it as such:
>
>myList = [1,2,"a",6,"g"]
>temp = array._shift(myList)
>array._push(myList,temp)
>
>put myList
>  [2,"a",6,"g",1]
>
>
>
>
>Array Parent --script's name (parent script)
>-------------------------------------------------
>on new me
>   return me
>end
>
>on _shift me, tempList --variable = array._shift(list)
>   myValue = templist[1]
>   deleteAt(tempList,1)
>   return myValue
>end
>
<snip>
-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[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