PDA

View Full Version : Same data in ListBox


jarx34
11-02-2008, 07:02 PM
I've doing an album with Vangelis discography
first page is only links to subpages with vangelis albums
But i have a big problem

If i get into album and in listbox get songs everything is ok but if i go to other page and return to same page songs are again copied into list box and everything messing up

how could i freeze this list that only when page loads will be 5 songs always the same not doubled if i again load this page

sorry for my english

Greetings

RizlaUK
11-02-2008, 07:07 PM
make a switch so the code only runs once

eg:

-- put in project startup event
bAllow=true

-- put in page onshow
if bAllow then
bAllow=false
-- your listbox code here




end

jarx34
11-03-2008, 04:18 AM
My code so far thats works

On Show :

--StatusDlg.SetMessage("Please wait while we search for mp3s in your My Documents folder");
--StatusDlg.Show(0, false);
tblFiles = File.Find("AutoPlay\\Audio\\Vangelis - Sex Power" , "*.wav", true , false , nil , nil);
if tblFiles then
for i,v in tblFiles do
local tblSplit = String.SplitPath(v)
ListBox.AddItem("ListBox1", tblSplit.Filename, v);
end
end
--StatusDlg.Hide();



On Audio

if (e_Channel == CHANNEL_BACKGROUND) and (e_State == "Finish") then
local tblSel = ListBox.GetSelected("ListBox1");
if tblSel then
local nNext = tblSel[1] +1;
if nNext > ListBox.GetCount("ListBox1") then
nNext = 1;
end
ListBox.SelectItem("ListBox1", nNext);
local sLBData = ListBox.GetItemData("ListBox1", nNext);
Audio.Load(CHANNEL_BACKGROUND, sLBData, true, false);
Page.StartTimer(500);
local tblSplit = String.SplitPath(sLBData);
nLen = Audio.GetLength(CHANNEL_BACKGROUND)
Label.SetText("Label2", tblSplit.Filename.. " - ".. SecondsToClock(nLen));
end
end

ListBox On Dblclick

tblSel = ListBox.GetSelected(this);
if tblSel then
local sLBData = ListBox.GetItemData(this, tblSel[1]);
Audio.Load(CHANNEL_BACKGROUND, sLBData, true, false);
ListBox.SetUpdate("ListBox1", false);
Page.StartTimer(500);
local tblSplit = String.SplitPath(sLBData);
nLen = Audio.GetLength(CHANNEL_BACKGROUND)
Label.SetText("Label2", tblSplit.Filename.. " - ".. SecondsToClock(nLen));
end

Project Gloobal Functions

function SecondsToClock(sSeconds)
local nSeconds = String.ToNumber(sSeconds)
if nSeconds == 0 then
--return nil;
return "00:00:00";
else
local nHours = string.format("%02.f", Math.Floor(nSeconds/3600));
local nMins = string.format("%02.f", Math.Floor(nSeconds/60 - (nHours*60)));
local nSecs = string.format("%02.f", Math.Floor(nSeconds - nHours*3600 - nMins *60));
return nHours..":"..nMins..":"..nSecs
end
end



Please help !!!