Darwin
02-21-2005, 06:58 PM
Hi,
I get this weird error when trying to unzip a file to my harddrive.
I just copied the example from the help file and changed the zip filename and password. I reckon i had this working a few months ago when testing the feature, but now i get an error:
OnClick, Line 38: attempt to index global `tblErrorMessages' (a nil value)
what do i have to put instead of a nil value? i don't want to define a special callback function.. :huh
here's my code
-- Allow the user to select a directory to unzip the files.
target_folder = Dialog.FolderBrowse("Select a Folder", "C:\\");
-- Check to see if the user cancelled or an error occurred.
if (target_folder ~= "CANCEL") and (target_folder ~= "") then
-- Gets a list of the contents of a zip file.
zip_contents = Zip.GetContents("AutoPlay\\Docs\\2.zip", true);
-- Get the error code of the last action.
error = Application.GetLastError();
-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
-- Take the table and turn it into a string with newlines for displaying.
zip_contents_display = Table.Concat(zip_contents, "\r\n", 1, TABLE_ALL);
-- Ask the user if they are sure they would like to unzip the contents.
result = Dialog.Message("Information", "The following files will be unzipped:\r\nClick the Cancel button to abort the process.\r\n\r\n"..zip_contents_display, MB_OKCANCEL)
-- If the user clicked Ok, unzip the files.
if (result == IDOK) then
-- Show the status dialog.
StatusDlg.Show();
-- Extract the contents of the Zip file.
Zip.Extract("AutoPlay\\Docs\\2.zip", {"*.*"}, target_folder, true, true, "mYpAssWorD", ZIP_OVERWRITE_NEVER, nil);
-- Check the error code for the last action.
error = Application.GetLastError();
-- Hide the status dialog.
StatusDlg.Hide();
-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Errror", tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
Dialog.Message("Success", "The unzipping was successful.", MB_OK, MB_ICONINFORMATION);
end
end
end
end
I get this weird error when trying to unzip a file to my harddrive.
I just copied the example from the help file and changed the zip filename and password. I reckon i had this working a few months ago when testing the feature, but now i get an error:
OnClick, Line 38: attempt to index global `tblErrorMessages' (a nil value)
what do i have to put instead of a nil value? i don't want to define a special callback function.. :huh
here's my code
-- Allow the user to select a directory to unzip the files.
target_folder = Dialog.FolderBrowse("Select a Folder", "C:\\");
-- Check to see if the user cancelled or an error occurred.
if (target_folder ~= "CANCEL") and (target_folder ~= "") then
-- Gets a list of the contents of a zip file.
zip_contents = Zip.GetContents("AutoPlay\\Docs\\2.zip", true);
-- Get the error code of the last action.
error = Application.GetLastError();
-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
-- Take the table and turn it into a string with newlines for displaying.
zip_contents_display = Table.Concat(zip_contents, "\r\n", 1, TABLE_ALL);
-- Ask the user if they are sure they would like to unzip the contents.
result = Dialog.Message("Information", "The following files will be unzipped:\r\nClick the Cancel button to abort the process.\r\n\r\n"..zip_contents_display, MB_OKCANCEL)
-- If the user clicked Ok, unzip the files.
if (result == IDOK) then
-- Show the status dialog.
StatusDlg.Show();
-- Extract the contents of the Zip file.
Zip.Extract("AutoPlay\\Docs\\2.zip", {"*.*"}, target_folder, true, true, "mYpAssWorD", ZIP_OVERWRITE_NEVER, nil);
-- Check the error code for the last action.
error = Application.GetLastError();
-- Hide the status dialog.
StatusDlg.Hide();
-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Errror", tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
Dialog.Message("Success", "The unzipping was successful.", MB_OK, MB_ICONINFORMATION);
end
end
end
end