5 Replies Latest reply on Jan 11, 2016 6:11 AM by jbrown

    Moving a delimited list from one script to the other

    Greth

      I've been looking for a specific solution for a while now, but haven't been able to translate the snippets I found to my exact situation. And It'd be nice to have some feedback on whether or not I'm completely insane for doing it this way in the global sense.

       

      So: I have a working solution, but I'm willing to learn about more efficient ways to do this. I'm slowly realising that - beyond the scope of this question - I'm practically making an SAP system in Filemaker, so some more insight would be wonderful:

       

      I am using FM11 Advanced with a host computer using FM10 regular. I have no opportunity to chance said host or upgrade any time soon (It's complicated).

       

      I have a list of invoice PDF files I've created so I can e-mail them to respective clients.

       

      The PDF names are loaded into a repeating variable: $PDFList[].

      I loop through all the invoices that I need to PDF, adding their ID to the respective $PDFList[$i]

      Then I create the PDFs looping through $PDFList[].

       

      Sample of the delimited list PDF IDs:

       

      ...

      0812150503

      0812150506

      0812150507

      0812150508

      ...

       

      Now, I work at an auction house. This is important because we have two types of client. The Buyers and the Sellers. The whole e-mail procedure needs to happen with both but with 'minor' differences. To the e-mail script this just means a different path to export/import and a different list of PDF IDs. So I want to use the PDF and mail part as a separate script, just handing down a parameter with the Delimited List and one with the origin of the information (Buyers or Sellers).

      So I have 'The Buyer script' and 'The Seller script' handing down information to 'The e-mail script'.

       

      For the life of me I haven't been able to get $PDFList[] transfered by parameter. It seems like it's impossible to have a repeating variable parameter?

       

      In any case, I'm now dumping the $PDFList[] into a global field, allowing the next script to simply take it from there. But I can't seem to tell the variable that the text is already delimited by ¶. So I've ended up making a second loop, going through the values in the global field and re-creating $PDFList[] from that information.

       

      Would it be easier to simply use $$PDFlist[] as a global variable? I don't know how this would affect performance. It seems bad form to use it.

       

       

      So the specific questions:

       

      1. Is it possible to pass the whole delimited list using Parameters in this situation? If so, ... Please just spell it out for me because I'm getting desperate.

      2. Am I fine just using a $$GlobalVariable instead?

        • 1. Re: Moving a delimited list from one script to the other
          jbrown

          You can certainly dump a variable into the script parameter to pass to the sub script.

           

          In this case, I wouldn't use a repeating variable. I'm not sure the benefit for this. Repeating variables, I think, are meant to sort of do a attribute::value kind of thing. Here you're just creating a list.

           

          So what I'd do is, in my loop, APPEND the PDF ID to the $PDFList variable. Do something like this in your loop:

           

          If (IsEmpty ($PDFList) ; YourTable::PDFID &"¶" ; $PDFList &"¶" & YourTable::PDF)

           

          Then you can pass that whole list $PDFList into the script parameter.

          • 2. Re: Moving a delimited list from one script to the other
            johan

            1. Yes, use List ( $PDFList ) to convert your repeating variable to a return delimited list, that could be sent as a script parameter. In the recieving end, you either loop through the list and do your magic, or if you prefer you can populate another repeating $PDFList in the receiving script.

             

            2. Yes. But be extra careful, you need to delete all repetitions in the $$variable before you use it again. Otherwise you may send the same invoice to multiple recipients.

            • 3. Re: Moving a delimited list from one script to the other
              BruceRobertson

              "1. Yes, use List ( $PDFList ) to convert your repeating variable to a return delimited list"

              No, that does not work. Did you actually try it before suggestion this?

              • 4. Re: Moving a delimited list from one script to the other
                Greth

                Hey, thanks for the reply. I called in sick on Friday so I wasn't able to take further part in the conversation.

                 

                It's kind of scary that this simple solution might do it. I was very hung up on the idea of using 'Arrays' that I tried to stick with the repeating values simply because they used an '$x[$i]' syntax.

                 

                I'll be sure to mark your answer when I get to do another pass on it.

                • 5. Re: Moving a delimited list from one script to the other
                  jbrown

                  It is a simple thing to do☺

                  Here's the correct calculation:

                  If (IsEmpty ($PDFList) ; YourTable::PDFID &"¶" ; $PDFList  & YourTable::PDF&"¶")

                   

                  You want to create the list and finish the list with a return character so that in your next run-through of the loop, the new PDF ID will be placed on the next line.