Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2007
    Posts
    5

    Grin Interesting Problem

    I have two (I think interesting) questions:

    First - how to write script that search a file and if that file isnt on that partition search another etc.Also I need to copy a file from application to that one.And last I need dialog message to notify user that file is or isnt found
    and when file is copied.

    Because I don know almost anything about writing script dont laugh at my
    attempt to write this one
    *problem is that first dialog shows and then second dialog show that file was copied but it isnt*

    Dialog.Message ("Please wait","File is being copying")
    result = File.Find("C:\\", "file.something", true, nil);
    if (result) then
    strnew = Table.Concat(result, "", 1, TABLE_ALL);
    File.Copy("AutoPlay\\Docs\\file2.something", strnew, true, true, false, true, nil);
    Dialog.Message ("File is copied","OK")
    else -- if file isnt found search another partition
    result1 = File.Find("D:\\", "file.something", true, nil);
    if (result1) then
    strnew1 = Table.Concat(result1, "", 1, TABLE_ALL);
    File.Copy("AutoPlay\\Docs\\file2.something",strnew 1, true, true, false, true, nil);
    Dialog.Message ("File is copied","OK")
    else
    result2 = File.Find("E:\\", "file.something", true, nil);
    if (result2) then
    strnew2 = Table.Concat(result2, "", 1, TABLE_ALL);
    File.Copy("AutoPlay\\Docs\\file2.something", strnew2, true, true, false, true, nil);
    Dialog.Message ("File is copied","OK")
    else
    Dialog.Message ("Error","File isnt found")
    end
    end
    end

  2. #2
    Join Date
    Mar 2007
    Posts
    5

    And second

    How to make file browse for user to select a specific file (file.something) an copy another in that path.Also if selected file isnt file.something then Dialog.message to notify that selected file isnt file.something.

  3. #3
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    Here's a project to get you started. This shows how to take a user entered filename and search all drives attached to the user's computer for that file.

    All of the important code is on the "Search Now" button ("Button1").

    Keep in mind that the File.Find() action in AMS returns a table of all files matching the search criteria. You should be prepared that the user's system might have more than one file matching the search. Maybe you want just copy the first on found or maybe you want to copy all of them. If you want the later, you'll need to decide how you want to prevent overwriting (because they might all have the same name).
    Attached Files
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  4. #4
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    Here's another example using your code...

    Code:
    --Dialog.Message ("Please wait","File is being copying")
    drives = Drive.Enumerate();
    
    
    for index, driveLetter in drives do
    
    	StatusDlg.Show();
        result = File.Find(driveLetter, "file.something", true, false); 
        StatusDlg.Hide();
        
        if (result) then
    		
            File.Copy(result[1], "AutoPlay\\Docs\\", true, true, false, true, nil); 
           
            Dialog.Message("File is copied","OK");
    
        else
    
            Dialog.Message("Error","File isn't found on " .. driveLetter);
    
        end
    
    end
    I added the StatusDlg actions so the user has something to see with the search occurs.
    Last edited by TJS; 03-21-2007 at 12:30 PM.
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  5. #5
    Join Date
    May 2006
    Posts
    5,380
    ok, heres some code for both your dilemers

    this will search all drives on the system, when the file is found the user will be asked if thay want to copy the new file

    it uses a callback function to dispaly the status dialog
    PHP Code:
    function Found (filename)
        
    Copy Dialog.Message("FOUND!!"filename .. " was found!!\r\nWould you like to copy file . . ."MB_YESNO);
            if 
    Copy == IDYES then
            Path 
    String.SplitPath(filename);
                
    File.Copy("AutoPlay\\Docs\\File2.txt"Path.Drive.."\\"..Path.Foldertruetruefalsetruenil);
                
                
    error Application.GetLastError();
                if (
    error ~= 0then
                    Dialog
    .Message("Error"_tblErrorMessages[error], MB_OKMB_ICONEXCLAMATION);
                else
                
    Dialog.Message("Error""File Copy OK"MB_OKMB_ICONEXCLAMATION);
                
    end
            end
        
    return false;
    end

    Drives 
    Drive.Enumerate();
    FileName "File.txt"--change this to your filename
    StatusDlg
    .Show();
    for 
    i,v in Drives do
        
    File.Find(Drives[i], FileNametruetruenilFound);
    end
    StatusDlg
    .Hide(); 

    this one will ask to fine the file, and compair it to the filename stored in the var "FileToLookFor", if it matches then user is asked if thay want to copy the new file

    PHP Code:
    FileToLookFor "myfile.txt"
    selFile Dialog.FileBrowse(true"Locate File"_DesktopFolder"All Files (*.*)|*.*|""""dat"falsefalse);
    if 
    selFile[1] ~="CANCEL" then
        sPath 
    String.SplitPath(selFile[1]);
        if 
    sPath.Filename..sPath.Extension == FileToLookFor then
            sCopy 
    Dialog.Message("Notice""File matches, would you like to copy new file."MB_YESNOMB_ICONINFORMATIONMB_DEFBUTTON1);
                if 
    sCopy == IDYES then
                    File
    .Copy("AutoPlay\\Docs\\File2.txt"sPath.Drive.."\\"..sPath.Foldertruetruefalsetruenil);
                    
    error Application.GetLastError();
                    if (
    error ~= 0then
                        Dialog
    .Message("Error"_tblErrorMessages[error], MB_OKMB_ICONEXCLAMATION);
                    else
                        
    Dialog.Message("Error""File Copy OK"MB_OKMB_ICONEXCLAMATION);
                    
    end
                end
        
    else
        
    Dialog.Message("Error""The file dose not match"MB_OKMB_ICONEXCLAMATION);
        
    end
    end 

    EDIT:, lmao.....every time i work on code for someone im always to late with the reply
    Open your eyes to Narcissism, Don't let her destroy your life!!

Similar Threads

  1. Problem installing fonts
    By ByronFS in forum Setup Factory 7.0
    Replies: 5
    Last Post: 05-08-2006, 12:23 PM
  2. Video Problem
    By ScottDuncan in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 07-10-2004, 01:38 PM
  3. PROBLEM: Setup Starts and then Crashes
    By Support in forum Setup Factory 5.0
    Replies: 0
    Last Post: 10-15-2002, 03:02 PM
  4. PROBLEM: Setup Requests Disk 2 in a Single File Setup
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-09-2002, 02:04 PM
  5. INFO: Tips for Debugging Action Lists in AutoPlay Media Studio 4.0
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-03-2002, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts