Filenames multiply when pagereloads

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rikard
    Forum Member
    • May 2005
    • 21

    Filenames multiply when pagereloads

    Hi I am very new to this program and programming.
    But I have managed to put together a test project with some help from examples.
    I have a couple of pages that takes me to an file browser, on the file browser page I have a back button ""Page.Navigate(PAGE_BACKWARD)"" when I then return to the file browser page it shows 2 of each file next time 3 and so on.
    What can I do to prevent that?

    Here is my code on the file browser page:

    ON PRELOAD

    --populate a table with all the files
    med_file = File.Find(_SourceFolder.."\\AutoPlay\\Docs\\Anlägg ningsdata", "*", false, false, nil);

    zero_file = File.Find(_SourceFolder.."\\AutoPlay\\Docs\\Anlägg ningsdata", "*", false, false, nil);


    -- An if statement that compares two numbers

    if zero_file == nil then
    -- Do something here

    do return end
    else
    --do the following for each file:
    for j,file_path in med_file do
    --add the item to the listbox, with the name visible and path as data
    ListBox.AddItem("File List", String.SplitPath(file_path).Filename, file_path);
    end

    --Allow the listbox to display the updated content
    ListBox.SetUpdate("File List", true);
    end
  • Worm
    Indigo Rose Customer
    • Jul 2002
    • 3971

    #2
    Before you add anything to the Listbox, remove all items to ensure that you don't get duplicates.


    Originally posted by Rikard
    Hi I am very new to this program and programming.
    But I have managed to put together a test project with some help from examples.
    I have a couple of pages that takes me to an file browser, on the file browser page I have a back button ""Page.Navigate(PAGE_BACKWARD)"" when I then return to the file browser page it shows 2 of each file next time 3 and so on.
    What can I do to prevent that?

    Here is my code on the file browser page:

    ON PRELOAD

    --populate a table with all the files
    med_file = File.Find(_SourceFolder.."\\AutoPlay\\Docs\\Anlägg ningsdata", "*", false, false, nil);

    zero_file = File.Find(_SourceFolder.."\\AutoPlay\\Docs\\Anlägg ningsdata", "*", false, false, nil);


    -- An if statement that compares two numbers

    if zero_file == nil then
    -- Do something here

    do return end
    else
    --do the following for each file:
    for j,file_path in med_file do
    --add the item to the listbox, with the name visible and path as data
    ListBox.AddItem("File List", String.SplitPath(file_path).Filename, file_path);
    end

    --Allow the listbox to display the updated content
    ListBox.SetUpdate("File List", true);
    end

    Comment

    • TJ_Tigger
      Indigo Rose Customer
      • Sep 2002
      • 3159

      #3
      Originally posted by Worm
      Before you add anything to the Listbox, remove all items to ensure that you don't get duplicates.

      I only remember to do that once I have seen items added to the list multiple times.
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment

      • Rikard
        Forum Member
        • May 2005
        • 21

        #4
        Thanks for the fast reply.
        I will probebly ask another question soon again

        Comment

        Working...
        X