Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list question

Status
Not open for further replies.

manfishj

Programmer
May 30, 2002
44
US
I'm using the code below in a frame script to add to an ongoing list. If
the sound file finishes playing, then that frame label gets added to the
list.
However, after something is added to the list, a bunch of 0's are added to the list for some reason.
Basically, a list that should be ["2", "3"] ends up looking like
this...[0, 0, 0, 0, "2", 0, 0, 0, 0, "3"]

Any idea why this is happening?

Thanks in advance.

Jon


on enterFrame

global gPagesCompletedList,gframeForCurrentSlide, gLabel

member("pageNo").text = the frameLabel

if sound(1).isBusy() then

go to the frame

else



gLabel = the frameLabel


gframeForCurrentSlide = marker (0)

doesMarkerExist = gPagesCompletedList.getOne(gLabel)


if doesMarkerExist <> 0 then

go next

else

gPagesCompletedList.add (gframeForCurrentSlide, gLabel)

go next


end if


end if


end

on exitFrame me


go to the frame


end






 
The first thing I'd look at is this line:
gPagesCompletedList.add (gframeForCurrentSlide, gLabel)

The command add(position, value) adds value into the position of the list. So, if gframeForCurrentSlide (the frame number of the current/last frame label) is 5, and gLabel (the frame label of the current frame) is "2", then the resulting list will be [0, 0, 0, 0, "2"] - the value "2" is added to the position 5 of the list.

Kenneth Kawamoto
 
If you are just adding values to a linear list like that you need to use the APPEND method, not the add method.

myLinearList.append(myValue)

As Kenneth said, the zeros are placeholders because you are stating the position in the list the value is to be added.
 
fugigoose is right, use "append" command. Actually you can use "add" to append the value to the unsorted list, however, if the list is sorted the value will be added to the position according to the alphanumeric order of the list.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top