PDA

View Full Version : file browse dialog causes problems?!?!?!


gnetcanada
12-16-2004, 05:32 PM
Hi Guys,

I have been spending the last 3 hours trying to get this to work in my project, and couldn’t, so I made a whole new project with the problem in it. The list box on page 2 is automatically populated by some code in the "Preload" Section, which looks for jpg files in a directory "Data", everytime page 2 loads, the first command is to delete all items from the listbox (to avoid adding duplicates everytime the page is accessed again). Now... this works fine if you simply switch between page 2 and page 1 (i.e. click page 2, then from page 2 click the page 1 button, do this many times, it works) BUT AS SOON as you try to browse for a file, by clicking the "File Browse" button on page 2, the whole thing go out the window, select any file, then press ok. Then press the "go to page 1 button" then go back to page 2 by pressing the page 2 button. The listbox is no longer being populated, its blank, all this is caused by just launching the file browse command.

download from: http://www.gnetcanada.com/problemwithfilebrowse.apz

Im bewildered, and EXTREMLY frustrated, any help would be good.

Shawn

Worm
12-16-2004, 05:44 PM
Shawn, the link is broken... :eek:

TJ_Tigger
12-16-2004, 08:43 PM
Will not break . . will not break . . . it broke . . .

gnetcanada
12-16-2004, 09:00 PM
hey guys, sorry. wouldnt let me post an apz, so try the zip:

http://www.gnetcanada.com/filebrowse.zip

Thanks,

Worm
12-16-2004, 09:21 PM
Shawn,

In your Page 2's Preload event, you have the following code. The line

file_table = File.Find("Data", "*.jpg", false, false, nil);

This is your problem line. It works until you've used the FileBrowse because by default AMS is using it's EXE folder as the working folder. Once you browse, the folder has changed. You need to change the line to this:

file_table = File.Find(_SourceFolder .. "\\Data", "*.jpg", false, false, nil);

to ensure that AMS will look in the correct folder. See the code below.



--delete all picture box data
ListBox.DeleteItem("ListBox_Advertisements", LB_ALLITEMS);

--fill picture box data
file_table = File.Find(_SourceFolder .. "\\Data", "*.jpg", false, false, nil);

if (file_table == nil or Table.Count(file_table)==0) then

else
file_count = Table.Count(file_table);
ctr = 1;
for i,file in file_table do
filetemp = String.SplitPath(file);
ListBox.AddItem("ListBox_Advertisements", filetemp.Filename, file);
end
listphotoitemnum = ListBox.FindItem("ListBox_Advertisements", LB_ALLITEMS, LB_BYTEXT, "Listing Photo");
if (listphotoitemnum~=-1) then --if Listing photo exists in the listbox, select that one, otherwise select item 1
ListBox.SelectItem("ListBox_Advertisements", listphotoitemnum);
picdata = ListBox.GetItemData("ListBox_Advertisements", listphotoitemnum);
else
ListBox.SelectItem("ListBox_Advertisements", 1);
picdata = ListBox.GetItemData("ListBox_Advertisements", 1);
end
end

gnetcanada
12-16-2004, 09:30 PM
hey worm, THANK You very much.... it is a little rediculous however though, how it works as it is, until you use the file browse dialog.

but thanks!

Worm
12-16-2004, 09:46 PM
I have to admit it kind of threw me. I do wonder know if there is an issue with the relative paths. I haven't looked any deeper into it.