View Full Version : Tables - What am I doing wrong?
TJ_Tigger
12-03-2003, 11:42 AM
I am trying to detect an Audio Finish state and then advance a selected index for a List box and load the selected list box. When I perform the following code, it says it is successful but then the application hangs. Here is what I am doing
if e_State == "Finish" then
lbcount = ListBox.GetCount("ListBox1")
selectedindex[1] = (selectedindex[1] + 1)
if selectedindex[1] > lbcount then
selectedindex[1] = 1
end
itemdata = ListBox.GetItemData("ListBox1", selectedindex[1]);
Audio.Load(CHANNEL_NARRATION, itemdata, true)
end
What I am concerned about is the selectedindex[1] = selectedindex[1] +1 line. I am not thinking that this is the correct way to manipulate a table. Only single selection is allowed in the list box, that is why I am using selectedindex[1].
Do I need to extract the table data then perform the addition then reset the table data?
tabledata = selectedindex[1]
tabledata = tabledata + 1
selectedindex[1] = tabledata
Tigg
Thanks
TJ_Tigger
12-03-2003, 12:05 PM
or maybe something convoluted like this
selectedindex[1] = ((index = selectedindex[1]) +1)
TJ_Tigger
12-03-2003, 01:56 PM
Here is the project that I am working on with the above code. You will have to create your own playlist for it to work, but the instructions are included in the project. And you will need .ogg audio files since that is what this project uses. What happens is that when the song engs I get the previously selecte index and increase the value by one and try to load that into my Audio channel. That is when it freezes. I believe that the code up to that point is working correctly, but when I debug it stops at the point when it tries to load the new song. Loading a new song by doubleclicking works just fine though. I cannot capture the text from debug since it freezes when loading the new .ogg audio. I will try to get a screen capture.
Brett
12-03-2003, 02:42 PM
TJ,
That is indeed a bug. I have spent the last half-hour poking around in the source code, but I found out the problem.
The hang is due to calling Audio.Load on the On Audio event. A workaround for now is to start a page timer when you detect the that channel is finished:
if ((e_Channel == CHANNEL_NARRATION) and (e_State == "Finish")) then
Page.StartTimer(200);
end
Then go to the page's timer event and do the following:
Page.StopTimer();
lbcount = ListBox.GetCount("ListBox1")
index = selectedindex[1]
index = index + 1
--selectedindex[1] = index
--selectedindex[1] = (selectedindex[1] + 1)
if index > lbcount then
index = 1;
end
itemdata = ListBox.GetItemData("ListBox1", index);
Audio.Load(CHANNEL_NARRATION, itemdata, true)
--end
That should do the trick until we can fix the bug...
TJ_Tigger
12-03-2003, 03:59 PM
Cool Thanks.
TJ_Tigger
12-04-2003, 06:36 AM
Brett,
Do you have any suggestions as to what I was doing wrong with the tables. In the original part of the post I was trying to numerically increase a value in a table. Should that be able to work? As I was playing around I ended up extracting the information from the table and increasing the value by one and using the new variable. I would think that I should be able to perform an addition function to data stored in a table.
Something like this. Since I am new to tables I am curious if this is a valid way to accomplish increasing the value stored in a table by one.
selectedindex[1] = (selectedindex[1] + 1)
The scripting guide talkes about updating a table but in the update they don't perform the above function.
Just Curious
Tigg
Lorne
12-04-2003, 09:01 AM
Yep, that should work fine, assuming the value at selectedindex[1] is a number.
TJ_Tigger
12-04-2003, 09:49 AM
Yep, it is a number, actually an index for a selected item in a list box.
Powered by vBulletin™ Version 4.0.6 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.