PDA

View Full Version : Save As


Moiz Palaci
07-01-2008, 04:06 PM
Hi,

I am trying to save an image stored on a CD to a Hard Drive, giving the user the option to "Save As".

can you help with the code, please.

Moiz

RizlaUK
07-01-2008, 04:26 PM
hi, you could use a simple script like below, edit the path to your file (marked in red)

tbFile = Dialog.FileBrowse(false, "Locate File", _DesktopFolder, "JPEG Files (*.jpg)|*.jpg|All Files (*.*)|*.*|", "", "dat", false, false);
if tbFile[1] ~= "CANCEL" then
File.Copy("C:\\path\\to\\your\\file.jpg", tbFile[1], true, true, false, true, nil);
-- Test for error
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
Dialog.Message("Success", "The file was saved to:\r\n"..tbFile[1], MB_OK, MB_ICONINFORMATION);
end
end

Moiz Palaci
07-05-2008, 08:56 AM
This is working perfectly.

Thanks,

I am trying to default the name to save to the name of the file, using a variable, but it gives me an error as it expects a string:

fileName = ThumbList.GetItemInfo("Pic_tn", selected[1]);

tbFile = Dialog.FileBrowse(false, "Save File", _DesktopFolder, "JPEG Files (*.jpg)|*.jpg|All Files (*.*)|*.*|", fileName, "", false, false);

can you advise.

RizlaUK
07-05-2008, 09:05 AM
ThumbList.GetItemInfo returns a table

try it like this:
tbInfo = ThumbList.GetItemInfo("Pic_tn", selected[1]);
if tbInfo then
tbFile = Dialog.FileBrowse(false, "Save File", _DesktopFolder, "JPEG Files (*.jpg)|*.jpg|All Files (*.*)|*.*|", tbInfo.fileName, "", false, false);
end

Moiz Palaci
07-05-2008, 01:40 PM
Thank you for your help