2 Replies Latest reply on Aug 19, 2009 1:34 PM by BetoBoton

    Learn to LOOP

    BetoBoton

      Title

      Learn to LOOP

      Post

      Ok Here is a good rookie question:

       

      Scenario:

      I have a script that converts a Longitude string to a numeric value.

       

      I want to create another script that calls this script and set the resulting calculated value to a field in my table (table::LongInSeconds)

      Here I want to assign ALL Records in this table to this value.

       

      How do you efficiently loop all records for this calculation to occur?

       

       

      idea 1 

      GoToRecord (Next) 

      If [Get (recordnumber) = Get (foundcount) ]

      Exit Script [] 

      Endif

      GoToRecord (Next) 

      Perform Script Calculation

      (How do you loop here? )

      ===============

       

      idea 2 

      Loop

      GoToRecord (Next) 

      Perform Script Calculation

      (how do you break not go go endless?)

      EndLoop 

       

       

       

      OR it is something I'm too tired to figure it out?

       

      Thanks for any suggestions

       

        • 1. Re: Learn to LOOP
          philmodjunk
            

          Some times the best loop is not to loop at all. The Replace Field Contents tool can be used to assign the same value, a serial number or a calculated value to the same field of every record in your found set.

           

          A looping primer:

          enclose the body of your loop between the script steps Loop and End Loop.

          Use the script step Exit Loop If [] to check and see if conditions for exiting a loop have occurred and if so exit the loop. (Execution continues with the next step after the End Loop step.)

          When you are looping through a found set of records and want to exit the loop after processing the last record in your found set, use Go To Record [next; exit after last].

          • 2. Re: Learn to LOOP
            BetoBoton
              

            Very wise!

            Thanks a lot.

             

            :smileywink:In this order:

            1- Had a shower

            2- Read your answer

            3- Understood

            4- Ready to implement

             

            cheers