2 Replies Latest reply on Feb 12, 2016 2:13 PM by Orion'sBell

    Help - Loop/Repetition Scripting Quandry

    Orion'sBell

      I'm writing a script that starts on a single record in Window A. It goes to Window B, loops through the current record set and loads up two local variables: $CarryBackNumber and $CarryBackSeries.


      Sample data looks like this:


      Repetition    $CarryBackNumber    $CarryBackSeries

      1              007                  Snow White

      2              055                  Snow White

      3              016                  Alice


      The script is then supposed to go back to Window A and load the repetions of the variables into the matching repetitions of two fields in the original record.


      Here's the section of script giving me the problem:


      Set Variable [ $RepetitionCounter : Value: 1 ]

      Loop

          Exit Loop If [ IsEmpty ( GetRepetition ( $CarryBackNumber : $RepetitionCounter ) ) ]

          Set Field [ Cards::Targeted Card Number[$RepetitionCounter] ; GetRepetition ( $CarryBackNumber ; $RepetitionCounter ) ]

          Set Field [ Cards::Targeted Card Series[$RepetitionCounter] ; GetRepetition ( $CarryBackSeries ; $RepetitionCounter ) ]

          Set Variable [ $RepetitionCounter : Value: $RepetitionCounter +1 ]

          Refresh Window [ ]

      End Loop


      Stepping through the script with the data viewer up I can see that $RepetitionCounter increases as it should and that the repetition data in $CarryBackNumber and $CarryBackSeries is good as I stated above.

       

      What happens is that the first repetion is set correctly, but then all subsequent repetions of $CarrBackNumber and $CarryBackSeries are ignored and instead the rest of the field repetions are filled with the first repetition of the variables.

       

      Here's what ends up in the fields of the originating record:

       

      Repetition    Targeted Card Number    Targeted Card Series

      1             007                     Snow White

      2             007                     Snow White

      3             007                     Snow White

       

      I'm sure it's a matter of just being too close to the problem to see the solution. Could someone please help with what I'm sure is a very obvious fix?

       

      Thanks.