PDA

View Full Version : ''backup'' menu help


TristanD
02-16-2007, 12:00 AM
i want to create a menu wich you can drop on a cd/dvd with other files like zip rar exe mp3. now i got the app to search for all files within the root and add them to a listbox but i cant get them to open on double click *within the LB*
everytime i try to open a file is displays the root folder in the explorer....

now i think the problem im having is that the file location is transported properly
so i tried a bunch of different ways but it still doesn't work..

there may be useless code in this project..

any help is welcome

Regards tristan,

Tek
02-16-2007, 10:10 AM
In your Global Functions you have the function called 'RunLBFile()'. The first line is 'Item = ListBox.GetSelected("ListBox1")' which returns a table of values so you will need to step through the results to perform actions on the results. Something like:


function RunLBFile()
Item = ListBox.GetSelected("ListBox1");
for index in Item do
Item_Data = ListBox.GetItemData("ListBox1", Item[index]);
Item_Name = ListBox.GetItemText("ListBox1", Item[index]);
...
...
...


That should get you started.

TristanD
02-16-2007, 10:14 AM
the location of the file is supposed to be set as the item data.. i figured getting the item data of the item double clicked on in the listbox would return the location of the file.. so it could be used for the file.open action..

am i missing something here?

Tek
02-16-2007, 10:47 AM
You are right but that wasn't what I was pointing out. The contents of the 'Item' that you use to get the selected item in the listbox returns a table, not a string. You need to step through these results in the 'Item' table to know which one was selected before you can get the item data.

An example is here on the online help:
http://www.indigorose.com/webhelp/ams60/Program_Reference/Actions/ListBox.GetSelected_Examples.htm

TristanD
02-16-2007, 11:26 AM
ahhh , now i get it... i didn;t quite understand you before but now i do, i will take a look into it and see if i can come up with some results, Thanks

Tek
02-16-2007, 11:56 AM
Cool. Post a new project if you get stuck again and we'll see where we can help.

TristanD
02-20-2007, 11:46 AM
could someone tell me why i get the error Attempt to call field extract(a nil value) with this?

function RunLBFile()
selected_items = ListBox.GetSelected("ListBox1");
if (selected_items ~= nil) then
output = "";
for index, item in selected_items do
output = output..item.."\r\n";
end
Loc = ListBox.GetItemData("ListBox1", output);
tbSplit = String.SplitPath(Loc);

if tbSplit.Extension == ".zip" then
folderr = Dialog.FolderBrowse("Please select a folder where the files should be extracted", "_SourceFolder");
Zip.Extract(Loc, {"*.*"}, folderr, true, true, "", ZIP_OVERWRITE_ALWAYS, nil);
else
end
else
File.Open(Loc, "", SW_SHOWNORMAL);
end

end

Tek
02-20-2007, 03:08 PM
I don't see any reference in that code to a string called 'extract'.

Maybe post your project file as the error is probably somewhere else.

TristanD
02-20-2007, 03:48 PM
thats the problem im having with ams for a while now.. it points to the zip.Extrac action and i dont know why...