How to make an app - Andromo App Maker

Announcement

Collapse
No announcement yet.

Script: Make Zip From Dialogs

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script: Make Zip From Dialogs

    this code will frist ask the user for the files to add to the archive
    then it will ask for the filename and location to save the zip file to
    once the file has successfuly been created it will open the folder that it was created in

    there is a series of error checking so if there is any error the user is informed

    this script is standalone ie: it dosent need any objects on the page to make it work

    copy and paste this code into your project or download the lua attached to this post

    PHP Code:
    -- Prompt the user to select files to add to the zip archive.
    FilesToAdd Dialog.FileBrowse(false"Files to Add"_DesktopFolder"All Files (*.*)|*.*|""""zip"truefalse);
    -- 
    Check to see if an error occurred, or the user cancelled.
    if (
    FilesToAdd[1] ~= "CANCEL") and (FilesToAdd ~= nilthen
        
    -- set the name and location of the new zip file
        SetZipName 
    Dialog.FileBrowse(false"Save File As"_DesktopFolder"All Files (*.zip)|*.zip|""""zip"falsefalse);
        -- 
    check that cancel wasent clicked and that a file name was enterd
        
    if (SetZipName[1] ~= "CANCEL") and (SetZipName ~= nilthen
        
    -- Show the status dialog.
        
    StatusDlg.Show();
        -- 
    Add the chosen files to the zip archive.
        
    Zip.Add(SetZipName[1], FilesToAddtrue""5nilfalse);
        -- 
    Get the error code of the zip.add action.
        
    error Application.GetLastError();
        -- 
    Hide the status dialog.
        
    StatusDlg.Hide();
            -- If 
    it succeededdisplay a success message and open the folderOtherwise display the error message.
            if (
    error == 0then
                Dialog
    .Message("Success""The files were successfully archived."MB_OKMB_ICONINFORMATION);
                -- 
    get the folder where the new zip file was created
                FullPath 
    String.SplitPath(SetZipName[1]);
                -- 
    Open the folder where the zip file was created.
                
    File.ExploreFolder(FullPath.FolderSW_SHOWNORMAL);
            else
                
    Dialog.Message("Error"_tblErrorMessages[error], MB_OKMB_ICONEXCLAMATION);
            
    end
        end
    end 
    Last edited by RizlaUK; 02-01-2009, 12:35 PM.
    Embrace change in your life, you never know, it could all work out for the best
Working...
X