Announcement

Collapse
No announcement yet.

Loop Table Entries to Perform Steps

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

  • Loop Table Entries to Perform Steps


    My latest project searches for folders containing a specific name and writes them to a table. I then do a table count on that table to see how many records it contains. If the count is 0 i exit the script.

    What i am having difficulty trying to understand is if i have records in the table. What i want to do is loop through the table records (hoping that is the correct term) so that i can use each record to update an ini file.

    Each record in the table is a folder name. So say my table is folder1fac, folder2fac and so on for however many it finds.

    I then want to undate an ini file that is in each one of those folders. Can anyone point me to a sample of code that explains how to do this?

    Below is my current code on how i am seaching for the folders and counting them:
    Code:
    -- Search MPN folder for any FAC folder
    fac = Folder.Find(_SourceFolder, "*fac", false, nil);
    
    -- Count number of FAC folders found
    count = Table.Count(fac);
    
    -- If no FAC folders, exist script
    if count == 0 then
     Application.ExitScript();
    else
    
    end
    Matt Leach
    GalacTek Corp.
    www.galactek.com

  • #2
    In order to loop over the elements of a table, you would typically use a for. See here.

    Code:
    for i = 1, #fac do
        Dialog.Message("debug", fac[i]);
    end
    The # operator will return the number of elements of the named table, and the result of #fac is the same as Table.Count(fac), just shorter and quicker to type.

    Ulrich

    Comment


    • #3
      Thank you Ulrich, much appreciated.
      Matt Leach
      GalacTek Corp.
      www.galactek.com

      Comment

      Working...
      X