From: Garek007 on
Hi,

I am trying to use a property list in my Director and because of this, I
cannot save or run my movie. Here is an example.

I have a function that runs on movie start and reads a text file putting the
elements into a property list. Later in the move I try to read from this list
with x = myList["2280"]

But because the list isn't created until the movie starts and runs my function
getData() the movie won't let me start? It tells me variable used before
assigned a value, but if the movie would just start it WOULD have a value!

What can I do?

Thanks,
Stan

From: Chunick on
Have you tested to see if the function is called and the variable containing
the property list is properly created?...

My frist guess would be that you haven't set the variable to be global. If you
are not familiar with variable scope then press F1 to bring up the help window
and in the search tap type in "scope" (without quotes) and you should see an
entry named "Variables" click on that and that should give you a clear
explanation.

The second thing I see is that myList["2280"] means that you are assigning the
value of the property "2280" to x. This seems to be a wasteful use of property
lists because your property name "2280" doesn't seem to have any significance
and if it refers to the position of the entry in the property list then it's
redundant. For example:

a property list:
pList = ["1": 3334, "2": 12, "3": 87, "4": 9008]
put pList["4"]
-- 9008

a list:
aList = [3334, 12, 87, 9008]
put aList[4]
-- 9008

There's little to no benefit in that example to use a property list over a
plain list. However, if the properties had meaning like this:

property list:
pHighScoreList = ["Jack": 3334, "LZR": 12, "Sub Zero": 87, "ACE": 9008]
put pHighScoreList["ACE"]
-- 9008

then we have a good use for property lists over plain lists because I can now
get the high score for a particular individual by using that person's name they
entered.

From: duckets on
is 'myList' supposed to be a global?

if so, maybe you forgot to put: "global myList" at the top of your script
which is causing the error.

The error "variable used before assigned a value" can be slightly misleading,
because you don't actually have to assign it a value. You just have to declare
that it's a property or a global. It then has a value of 'void', which is
technically 'unnassigned', but your code should now work,

hopet this helps,

- Ben



From: the real POTMO on
there are actually two types of lists.
Linear lists and property lists.

the linear list can be accessed by using its index
myList = ["yeah", "wow", "fresh"]
put myList[2]
--wow

the propertyList can be accessed by using index or key.

myList = ["propone" : "yeah", "proptwo" : "wow", "helloworld" : "fresh"]
put = myList[2]
-- wow
put = myList["propone"]
--yeah

you can also use symbols as keys ("I think its a bit quicker")
myList = [#propone : "yeah", #proptwo : "wow", #helloworld : "fresh"]
put myList[#propone]
--yeah
or with dot syntax
put myList.propone
--yeah

if you use dot syntax and the key does not exist youll get an error.
if you use [] syntax youll get void as result with keys not existing.

myList = [#propone : "yeah", #proptwo : "wow", #helloworld : "fresh"]
also you can write myList[#somenewprop] = "woha"
if the key does not exits it will add it and the value.
put myList
--[#propone : "yeah", #proptwo : "wow", #helloworld : "fresh",
#somenewprop:"woha"]



remember if you use strings as keys the keys are case sensitive "propOne" <>
"propone"

if you use symbols as keys you cant have a number as first char in the key
#1223key = BAD
#key1223 = GOOD
if you use strings as keys its ok to have numbers as first chars or numbers
only
like "1223key" = OK





so the soultion to yor problem:
i think youre accessing the list with x = myList["2280"] instead of x=
myList[2280]

a bit of a overkill help but it might help someone




From: Garek007 on
POTMO, 2280 is actually a string not a reference to a position in the list, so
it should still be "2280" no?

Chunick,
Maybe I could use a regular list, it would be a hell of a lot easier. Here's
what I am trying to do, please tell me what would work best. I have an excel
file that I exported to a tab delimited text file. In essence it's a table of
values. I need to be able to read those values in and call them up at will.
It seems like a property list would make that easier because I can have each
line referenced as a category and then call items in that line using the first
word of that line, in this case "2280". Am I overcomlicating this?

 |  Next  |  Last
Pages: 1 2 3
Prev: open audio part of e-CD
Next: Lingo Scripting