File Find Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • mustafa06
    Forum Member
    • Jul 2007
    • 287

    File Find Question

    ----- CODE

    function avanzar ()
    pos = Progress.GetCurrentPos("Plugin1");
    if pos == 100 then pos = 1
    else pos = pos + 10 end
    Progress.SetCurrentPos("Plugin1", pos);
    return true;
    end


    Progress.SetText("Plugin1", "");
    Progress.SetCurrentPos("Plugin1", 0);
    Progress.SetRange("Plugin1", 0, 100);
    Plugin.SetVisible("Plugin1", true);



    bshowFindtext = true;

    while bshowFindtext do
    Progress.SetText("Plugin1", "Searching");
    a = File.Find("E:\\", "*.mp3", true, false, nil, avanzar);
    bshowFindtext = false;
    end


    howmany = Table.Count(a); ----- PROBLEM LINE 26

    Progress.SetText("Plugin1", "Sorting...");
    for k in a do
    data = a[k];
    name = a[k];
    ListBox.AddItem("ListBox1", name, data);

    pgresspos = ((k / howmany) * 100);
    Progress.SetCurrentPos("Plugin1", pgresspos);
    if k == howmany then
    Plugin.SetVisible("Plugin1", false);
    end

    end

    ----- END


    Doesnt work because problem line 26 howmany = Table.Count(a);
  • ShadowUK
    No longer a forum member
    • Oct 2007
    • 1321

    #2
    Sometimes File.Find returns nothing meaning you should check if it is a table by doing something like this.

    Code:
    if (tFileFindResult) then
       -- continue
    end
    Or even to check if it has more than one result

    Code:
    if (tFileFindResult and Table.Count(tFileFindResult) > 1) then
       -- continue
    end
    Or just to check the type.

    Code:
    if (type(tFileFindResult) == "table") then
       -- continue
    end

    Comment

    • mustafa06
      Forum Member
      • Jul 2007
      • 287

      #3
      ok now work
      Last edited by mustafa06; 07-31-2008, 06:47 AM.

      Comment

      • siray
        Forum Member
        • Oct 2006
        • 120

        #4
        To shadow uk or mustafa06:

        if i want to create a button to stop that Find operation, can you give me example of script on On click button (stop button), and should i add some script lines between that script above if stop button is clicked (mustafa06's script)?

        Thanks for your answer

        Comment

        • arb
          Indigo Rose Customer
          • Jul 2007
          • 163

          #5
          Originally posted by siray View Post
          To shadow uk or mustafa06:

          if i want to create a button to stop that Find operation, can you give me example of script on On click button (stop button), and should i add some script lines between that script above if stop button is clicked (mustafa06's script)?

          Thanks for your answer
          I think you can make a button that sets a variable true to continue or false to stop, then you can use CallbackFunction of find action to check the variable each time for continue the operation or not.

          Comment

          • siray
            Forum Member
            • Oct 2006
            • 120

            #6
            Originally posted by arb View Post
            I think you can make a button that sets a variable true to continue or false to stop, then you can use CallbackFunction of find action to check the variable each time for continue the operation or not.
            Thanks arb, i'll try it.

            Comment

            • RizlaUK
              Indigo Rose Customer
              • May 2006
              • 5478

              #7
              from one of my code templates

              Code:
              function AddFile(strFilePath)
              	-- add callback events here
              	
              	
              	if bCancle then
              		return false
              	else
              		return true	
              	end
              end
              
              
              local sFolder = Dialog.FolderBrowse("Please select a folder:", Shell.GetFolder(SHF_MYDOCUMENTS));
              if sFolder ~= "CANCEL" then
              	bCancle=false
              	tbFile = File.Find(sFolder, "*.*", false, false, nil, AddFile);
              end
              Code:
              -- cancel button code
              bCancle=true
              Embrace change in your life, you never know, it could all work out for the best

              Comment

              • siray
                Forum Member
                • Oct 2006
                • 120

                #8
                Thanks mr Dean :yes

                Comment

                Working...
                X