3 Replies Latest reply on Feb 28, 2013 8:48 AM by philmodjunk

    Extracting from a list

    dhillock

      Title

      Extracting from a list

      Post

           I have a variable ($cMyListOfFiles) and it contains -- guess what -- a list of files from a folder. Each filename is on a separate line.

           Using PatternCount, I know how many files are in the list. I therefore have $nNumberOfFiles.

           I setup a loop that will loop for the number of files.

           My problem is that I cannot figure out how to pull-out the filename related to the loop iteration. For example on the first iteration of the loop, I want the first file name. This will be stored in $cTheCurrentFile. On the second iteration of the loop, I want to extract and store in $cTheCurrentFile, the second file in the list.

           I'm sure there is a straightforward way of doing this...but I cannot see how it's done. All suggestions are appreciated.

        • 1. Re: Extracting from a list
          philmodjunk
               

                    Using PatternCount, I know how many files are in the list. I therefore have $nNumberOfFiles.

               ValueCount can do that for you.

               GetValue ( $cMyListOfFiles ; $LoopCounter )

               Can be used to extract a different file name from the list with each pass through your loop. (Increment $LoopCounter each time.)

          • 2. Re: Extracting from a list
            dhillock

                 Thank you for the GetValue suggestion - works perfectly!

                 PatternCount was working for me because I knew that every line began with "filemac". However, you suggestion is more flexible, as it will not matter if I'm running on a Mac or PC.

                 Thank you again.

            • 3. Re: Extracting from a list
              philmodjunk

                   And here I thought you were using this to count the values: wink

                   PatternCount ( TextFeld ; ¶ ) + 1 - Isempty ( TextField )