This content has been marked as final. Show 4 replies
At first glance I see 2 possible issues
1) There's no begin movie eventm instead use startMovie
2) Every handler referencing a global must desclare it at the beginining
of the handler (or at the very top of a script member so all handlers
use the global)
global ghighscoreslist --
ghighscoreslist = value(getPref("topscores.txt"))
if voidp(ghighscoreslist) then
set ghighscoreslist =  -- initialize empty list
Strincly speaking, the .txt extension is not needed for pref files.
For a quick set/get pref test, ry entering the following in the message
window ( my director is too faar away for me to try it )
setPref "prefTest", string( [2, 4, 6] )
put getPref("prefTest") -- raw string
put value(getPref("prefTest")) -- list form
Sorry I am using start movie, that was just a typo i didnt copy it exactly from my script and I have all the globals declared. What is the correct lingo for sorting and adding to a property list, I think thats where my probles may lie.
Actually it seems to be working, thanks that test helped me get my head around the whole string/getpref/setpref thing. But the name doesn't seem to be added to the list with the score and also the list is being sorted by the property, not the value, if that makes sense?
Normally one appends to a prop list using
adProp theList, newPropName, newPropValue
Sorting property list has limited value, since it's expected that one
accesses properties by name. Prop lists seem to sort by value if each
prop's first value and not by prop name.
You can use findPosNear() on a sorted list to get the index number of the next closest entry to the value you are looking for:
myList = ["Bart", "Homer", "Lisa", "Maggie", "Marge"]
myIndex = myList.findPosNear("Margaret")
This can be useful in address books and type-ahead input fields and similar schemes. This works with both linear lists and property lists.