PDA

View Full Version : listbox problems!!!


stickck
12-30-2005, 10:41 AM
alright, where am i going wrong? i have a listbox that is populated with the lua files in the script folder. when i double-click i want that lua file to load. its not working. any ideas?

atbFiles = File.Find(_SourceFolder.."\\AutoPlay\\Scripts", "*.lua", false, false, nil,nil);
if atbFiles then
for i,v in atbFiles do
ListBox.AddItem("ListBox1", String.SplitPath(v).Filename, v);
end
end and this is the double-click ( i also but this same code on the button, on-click)atbSelected = ListBox.GetSelected("ListBox1");
if atbSelected then
astrScript = ListBox.GetItemData("ListBox1", atbSelected);
Application.LoadScript(astrScript);
end

another question... how can i make changes to one of the questions and have it save the changes back to the LUA file?

thanks for any suggestions on the second question. i've been looking for an answer for that one but just cant figure out a salution.


chris

Daniel TM
12-30-2005, 11:50 AM
atbFiles = File.Find(_SourceFolder.."\\AutoPlay\\Scripts", "*.lua", false, false, nil,nil);
if atbFiles then
for i,v in atbFiles do
ListBox.AddItem("ListBox1", String.SplitPath(v).Filename, v);
end
end

atbFiles refers to the File.Find action that returns a table. You just typed in the name of the variable that refers to the action File.Find. When there's an action that returns a table you have to type in the name of the variable . key.
Example:
result = File.Find("C:\\MyDir\\", "*.pdf", false, false, nil, nil);
After this line you can't just type in "result". you have to type in result.Folder or result.Filename or any other key from the table that the action File.Find returns.
This is what File.Find returns:
(table)
KEY_______________________TYPE
Folder_____________________string
Filename___________________string
Recurse___________________booblean
IncludeFolders______________booblean
CallbackFunction____________function
FileFoundCallbackFunction____function
I hope that helps. Good luck!

stickck
12-31-2005, 07:12 AM
alright! here is what i had...atbSelected = ListBox.GetSelected("ListBox1");
if atbSelected then
astrScript = ListBox.GetItemData("ListBox1", atbSelected);
Application.LoadScript(astrScript);
end
and this is what fixed it.
atbSelected = ListBox.GetSelected(this);
if atbSelected then
astrScript = ListBox.GetItemData(this, atbSelected[1]);
Application.LoadScript(astrScript);
end
this is the code used under the double-click

chris