Problem with Empty Table Handling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • madsen
    Indigo Rose Customer
    • Jun 2004
    • 77

    Problem with Empty Table Handling

    I have this little problem

    Code:
    01 files_source_folder = File.Find(source_folder, "*.*", false, false, nil);
    02 all_file_count = Table.Count(files_source_folder);
    Line 02 gives me the error "...argument 1 must be of type table" WHEN I select an EMPTY folder.

    I tried to use some error handling but it doesn't work. How do you suggest to make it?

    Thank you in advance!
    Human Relativity: No one is alike, which is what makes us alike, at any given time. --Myself
  • Corey
    Indigo Rose Staff Alumni
    • Aug 2002
    • 9745

    #2
    Hi. From the File.Find section in the help file:

    File.Find(); Returns:
    (table) A table containing the paths to all of the files that were found. If no files were found or an error occurs, nil is returned. You can use Application.GetLastError to determine whether this action failed, and why.

    Hope that helps...

    Comment

    • madsen
      Indigo Rose Customer
      • Jun 2004
      • 77

      #3
      Does't help

      I used Application.GetLastError and it returns 0 as nothing wrong would happen.

      The help file is my first resource when I don't know something, then this forum which I always found what I needed but now I'm stuck! But I'll find a way !!! I will post it here

      Thanks Corey!
      Human Relativity: No one is alike, which is what makes us alike, at any given time. --Myself

      Comment

      • madsen
        Indigo Rose Customer
        • Jun 2004
        • 77

        #4
        Thanks!

        Solved, thanks for oppening some path into my mind with this one


        Code:
        files_source_folder1 = File.Find(source_folder, "*.*", false, false, nil);
        
        
        if files_source_folder1 then
        all_file_count = Table.Count(files_source_folder1);	
        else
        all_file_count = 0;	
        end
        Thanks!
        Human Relativity: No one is alike, which is what makes us alike, at any given time. --Myself

        Comment

        • Corey
          Indigo Rose Staff Alumni
          • Aug 2002
          • 9745

          #5
          Glad to hear you got it fixed! Nice job... :yes

          Comment

          • TJ_Tigger
            Indigo Rose Customer
            • Sep 2002
            • 3159

            #6
            Welcome to the Self-Help forums with prompting from Corey.
            TJ-Tigger
            "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
            "Draco dormiens nunquam titillandus."
            Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

            Comment

            Working...
            X