13 Replies Latest reply on Feb 1, 2012 11:59 AM by BruceRobertson

    Repetitions in a script variable.

    benniemc

      I must be doing something wrong.

      (I've consulted Help, Missing Manual, & FM Training Series)

       

      Within a script a variable is set. (e.g.-$x)

      The script collects info from a repeating field in one table (10 repetitions).

      It stores the data in the 10 repetitions of the variable.

      The script goes to another table's layout.

      Only the first item remains in the variable. Repetitions 2...10 are lost.

      The data seems to be OK in the variable using the data watcher, until going to the other table.

      I've tried global variable ($$). It still doesn't work.

      I've scratched my head so long, I'm beginning to lose my hair!

       

      Thanks.

        • 1. Re: Repetitions in a script variable.
          comment

          benniemc wrote:


             The data seems to be OK in the variable using the data watcher, until going to the other table.

           

          Could you post a file showing this?

          • 2. Re: Repetitions in a script variable.
            PSI

            Hi benniemc,

             

            I'm not sure why the Variable is loosing the data but you don't need to use the repetitions. just stack the values in a return delimited list, add a return at the end.

             

            Then you can use GetValues () so if you are looping set 2 variables one that counts the returns the other that increments.

             

            Set Variable ( $CT ; PatternCount ( $VarWithData ; ¶ ))

            Set Variable ( $CTR ; 1 )

            loop

            set field [ receivingfield ; GetValue ( $VarWithData ; CTR )

            whatever else you need to set

            Exit Loop [ $CTR >= $CT ]

            Set Variable ( $CTR ; $CTR + 1 )

            End Loop

             

            John Morina

            Pueblo Systems, Inc.

            benniemc wrote:

             

            I must be doing something wrong.

            (I've consulted Help, Missing Manual, & FM Training Series)

             

               Within a script a variable is set. (e.g.-$x)

               The script collects info from a repeating field in one table (10 repetitions).

               It stores the data in the 10 repetitions of the variable.

               The script goes to another table's layout.

               Only the first item remains in the variable. Repetitions 2...10 are lost.

               The data seems to be OK in the variable using the data watcher, until going to the other table.

               I've tried global variable ($$). It still doesn't work.

               I've scratched my head so long, I'm beginning to lose my hair!

             

            Thanks.

            1 of 1 people found this helpful
            • 3. Re: Repetitions in a script variable.
              benniemc

              I've attached a sample file. I hope I haven't removed a critical component. Thanks for the response.

              benniemc

              • 4. Re: Repetitions in a script variable.
                benniemc

                Thanks for the response. I'll give your suggestion a try tonight. If it solves the problem, I'll make sure to mark it correct tomorrow.

                benniemc

                • 5. Re: Repetitions in a script variable.
                  PSI

                  I don’t see the sample file…

                   

                   

                   

                  John Morina

                   

                  Pueblo Systems, Inc.

                   

                  CCQ-FM Inc.

                   

                  O: 631.549.0969

                   

                  C: 516.443.0966

                   

                  john@pueblo-systems.com

                  • 6. Re: Repetitions in a script variable.
                    benniemc

                    It is called sample and was attached to my copy above your previous post. I'll resend it tonight. Sorry!

                     

                    Bennie McElhaney

                    405-501-4627

                    bennie@snewssoftware.com

                    • 7. Re: Repetitions in a script variable.
                      benniemc

                      John…

                       

                      Here is the sample file. Let me know if you don't receive it. It is only 147K, so it shouldn't be removed by your server.

                       

                      Hope this get through. I really appreciate your help.

                       

                       

                      Bennie McElhaney

                      501-4627 Cell

                      360-3332 Home

                      bennie@snewssoftware.com

                      • 8. Re: Repetitions in a script variable.
                        comment

                        Bennie,

                         

                        No file is atached. It looks like you are trying to do this ia email. Perhaps you should log into the forum and attach it there.

                        • 9. Re: Repetitions in a script variable.
                          StephenWonfor

                          benniemc

                           

                           

                          I have a small code snippet taped onto my old MacBook Pro.  It comes from a loop.

                           

                          Set Variable [ $Count;$Count + 1]

                          Set Variable [ $Name[$Count]; Value:SomeDataField]

                          Set Variable [ $Result; Value:Evaluate("$Name[5]")]

                           

                          If my memory serves me well, this was how to get data out of a repeating variable.  But now it does look sketchy...

                           

                          If not functional, you should consider stacking your variable with ¶ delimited data and using GetValue() to get what you need,  I seem to recall a wasted weekend with the idea of a repeating variable until it dawned on me that I could simply pretend it was repeating and use GetValue() and ValueCount().  I also recall some pipe-shifting (swapping and unswopping the "¶" chars for "|" in the captured data) so as not to break the "repetitions".

                           

                          Stephen

                           

                          ---

                           

                          "Tiger, tiger with refulgent conflagration

                          In the nocturnal afforestation,

                          Kindly provide details regarding

                          Nature of supernatural deity

                          Responsible for your design and technology"

                          ---William Blake (via his P.R. Guy)

                           

                           

                           

                          1 of 1 people found this helpful
                          • 10. Re: Repetitions in a script variable.
                            RayCologon

                            benniemc wrote:

                            Here is the sample file...

                             

                            Hi Bennie,

                             

                            The issue here is that you can't use the GetRepetition( ) function to retrieve the contents of a repeating variable - that's for use with repeating fields only. Instead you should use standard array notation. So, for example, the calculation expression for the Set Field [ ] step that targets the Transactions::TrxAccount field at line 25 of your "RecordJE" script should be:

                             

                            $trxacct[$row]

                             

                            If you change lines 25 and 26 to use this form instead of using the GetRepetition( ) function, your script will retrieve the successive repetitions as you were intending.

                             

                            Regards,

                            Ray

                            ------------------------------------------------

                            R J Cologon, Ph.D.

                            FileMaker Certified Developer

                            Author, FileMaker Pro 10 Bible

                            NightWing Enterprises, Melbourne, Australia

                            http://www.nightwingenterprises.com

                            ------------------------------------------------

                            • 11. Re: Repetitions in a script variable.
                              benniemc

                              Thanks, Ray! Your advice solved the problem.

                              Curoius why that wasn't covered in the docs or help.

                              Guess that's why this forum is so valuable.

                              Thanks, again.

                              benniemc

                              • 12. Re: Repetitions in a script variable.
                                timwhisenant

                                Hi Bennie,

                                 

                                 

                                 

                                History precludes that notation in the documentation.

                                 

                                The function GetRepetition() “introduced in version 3”, has been around in Filemaker much longer than variables have, so it’s an old leopard that only chased repeating fields whose spots did not change with the introduction of variables in version 8.

                                 

                                Welcome to the zoo.

                                 

                                 

                                 

                                Tim

                                • 13. Re: Repetitions in a script variable.
                                  BruceRobertson

                                  "I'm not sure why the Variable is loosing the data but you don't need to use the repetitions. just stack the values in a return delimited list, add a return at the end."

                                   

                                  No, that doesn't work.

                                   

                                  If your data has returns in it, or if you need to have a "sparse array" then the array notation is required.

                                   

                                  By sparse array I mean that perhaps you need to set $$something[25] and $$something[1] and $$something[293] but not other values. You might do this if you are using integer record ID values as the value.

                                   

                                  Note also that the array notation for variables allows for zero and negative integers. $$somthing[0] and $$something[-254] are valid.

                                   

                                  Array notation works for repeating fields but of course you cannot have a zero or negative repeating field instance.