Announcement

Collapse
No announcement yet.

Progess bar help

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

  • Progess bar help

    Hello,

    I'm trying to add a progress bar to a file find function. Below is the code that I have and I'm not sure how to incorporate the progress to step through the search.

    What I have are several input boxes, that allows the user to type a drive letter and the below code will search for a specific file, then writes all the paths to a txt file.

    Thanks!

    Code:
    get = Input.GetText("Input1");
    get2 = Input.GetText("Input2");
    
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter", get, REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter2", get2, REG_SZ);
    
    does_exist = Drive.GetInformation(get);
    
    
    if get == "" then
     --Dialog.Message("Notice", "blank", MB_OK, MB_ICONINFORMATION);
    
    elseif does_exist then
    
    my_docs_path = get;
    
        search_results = File.Find(my_docs_path, "_TEST_File.html", true, false, nil, nil);
    
                 message = "_HTML_instructions.html was found in the following location(s). Click OK to delete the file(s):\r\n\r\n";
                for index, path in pairs(search_results) do
                    message = String.Concat(message, path.."\r\n");
                    --TextFile.WriteFromString("C:\\ServerGuard\\Results.txt", "------ WARNING -----\r\n", true);
                    TextFile.WriteFromString("C:\\ServerGuard\\Results.txt", System.GetDate(DATE_FMT_US).." | "..System.GetTime(TIME_FMT_AMPM).." | File(s) found at " ..path .." .\r\n", true);
                    --TextFile.WriteFromString("C:\\ServerGuard\\Results.txt", "File(s) " ..path .." .\r\n" , true);
                end
                  end

  • #2
    So, instead of using the progress bar, I found the StatusDlg. It seems to work ok except now I get and error on "for index, path in pairs(search_results) do". Why am I getting this error? What did I mis in the code? Thanks

    Code:
    findme = Input.GetText("Input6");
    
    
    get = Input.GetText("Input1");
    
    
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter", get, REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter2", get2, REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter3", get3, REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter4", get4, REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "DriveLetter5", get5, REG_SZ);
    
    Registry.SetValue(HKEY_CURRENT_USER, "Software\\DriveGuard", "FileName", get6, REG_SZ);
    
    
    does_exist = Drive.GetInformation(get);
    
    
    if get == "" then
     --Dialog.Message("Notice", "blank", MB_OK, MB_ICONINFORMATION);
    
    elseif does_exist then
    
    
    my_docs_path = get;
    
        --search_results = File.Find(my_docs_path, "_HTML_instructions.html", true, false, nil, nil);
        StatusDlg.Show(MB_ICONNONE, false);
      StatusDlg.ShowCancelButton(true, "Cancel");
     StatusDlg.ShowProgressMeter(false);
        
         StatusDlg.Show();
          search_results = File.Find(my_docs_path, findme, true, false, nil, nil);
    
                 message = "_HTML_instructions.html was found in the following location(s). Click OK to delete the file(s):\r\n\r\n";
                 -- Show the status dialog.
                
                for index, path in pairs(search_results) do
                    message = String.Concat(message, path.."\r\n");
                    TextFile.WriteFromString("C:\\MySearch\\Results.txt", System.GetDate(DATE_FMT_US).." | "..System.GetTime(TIME_FMT_AMPM).." | File(s) found at " ..path ..".\r\n", true);
                  StatusDlg.Hide();
                   end
                  end

    Comment


    • #3
      What is the error msg and what values stored in variables "findme" and "my_docs_path"?

      If you incorrectly call File.Find then it will return Nil which would result in an error at pairs(search_result) because their is no table.

      Comment

      Working...
      X