1 Reply Latest reply on Mar 8, 2016 5:47 AM by mikebeargie

    Script to output multiple rows per input record


      Script to write items to a file


      I am using FileMaker Pro 13


      I am writing a script. I have three email fields that, if they are not blank, need to be added to a master email list. I know how to use a script to export a found set to a file. I know how to scroll through a found set to find data. What I do not know how to do is write to a file (as opposed to an export) as I scroll through the found set.

      What I am basically looking for is a line feed to an excel or tab delineated file.

      My output will create up to three records/rows for each record I read from the found set. It is as if I was inserting a line feed between each of these three fields... but only if the field contains data.

        • 1. Re: Script to output multiple rows per input record

          First, just use List ( email1 ; email2 ; email3 ) for your output, this will automatically omit blank values and return a delimited list of values.


          As for appending to an existing file, plugins like Troi File and Monkeybread allow you to append text to external files, however if you're dealing with a text file likst TAB or CSV, you can do something like the following:

          Set Variable [ $file ; path to your file ]

          Insert From URL [ $file ; table::tempField ]

          Set Field [ table::tempField ; List ( table::tempField ; email1 ; email2 ; email3 ) ]

          Export Field Contents [ table::tempField ; $file ]

          Basically read the file contents into a temporary text field, append your values to it, then re-export it to it's original location. There might be some additional steps you need to take but it's possible. The plugins will allow you to append or substitute in the external file without having to read it in and rewrite the entire file each time.