6 Replies Latest reply on Mar 15, 2016 2:17 PM by BillisSaved

    IF Statement Question


      I have one field of repeating values that will all be numeric values such as 0, 1, 2, 3, etc...

      I am trying to perform a test to do something if the value in a specific repetition is greater than zero, but if it is equal to zero do nothing.


      The portion of the macro I'm having issues with looks like this:


      If [Field1[1] ≠ 0}

        Set Field [Field2; 99]

      End IF


      In the example above, if the value in the first repetition of Field1 is 0 I would expect it to do nothing.

      If it is any value other than 0 I would expect it to set Field2 to 99.


      When in reality it is setting Field2 to 99 regardless of the value in the first repetition of Field1.



      (And please no comments regarding my use of repeating fields, i'm only trying to figure out why the logic doesn't work).

        • 1. Re: IF Statement Question

          For the first repetition you need not use the brackets.

          Is field1 defined as numeric?

          • 2. Re: IF Statement Question

            Actually upon looking at it, I figured out that macro portion was fine, my issues are elsewhere.

            If I have a repeating Field that looks like this:








            I have been using the LIST command to turn that into:





            I then set a field to that value, But that puts all those values into the first rep of the field, it doesn't put each value into the first available rep of that field. I don't see an easy way of turning a field with repeating values into the same field just eliminating all the empty reps.

            • 3. Re: IF Statement Question

              1) Evaluate CODE(Field1[1]) in DataViewer, what does it report ?

              2) We don't know what comes after the End IF.

              3) It's ok to use [1] even if omitting it is legit, makes all coherent

              4) curly brackets are really sexy.

              • 4. Re: IF Statement Question

                You could try:

                if [getasnumber(Field[1]) ≠ 0]

                    Set Field[Field[2] ; 99]

                End If

                • 5. Re: IF Statement Question

                  if aList is your list, try defining your repeating field as



                  l = Get ( CalculationRepetitionNumber ) ;

                  l1 = Extend(aList) ];

                  GetValue(l1; l)


                  • 6. Re: IF Statement Question

                    Good afternoon andrewma,


                    I hope your day is going well. Take a look at this sample file, it may give you an idea of how you can remove the empty values from your repeating field. There are two scripts: one populates the repeating field values, and the other reorders them. I used two fields so that you could see the difference, but in your case you may want to reference the same field in the loop as you do in the list() step. Hope this helps. Good luck.


                    God bless,