0

I am new to AMP, and currently trying the following with for:

        set @len = indexOf ([listofemails],';')
        if @len > 0 then
            for @part = indexof([listofemails],';') to 0 do
                @remainder = Add (@remainder,@ONE)
                /* script to update listofemails here*/
            next @part
        endif

So basically I want to check how many sub-strings exist separated by semicolon, and use that value later. Right now my for statement is not executing at all, seems to be having some issue. Can somebody help me out.


EDIT

Thanks to @Gortonington for the answer - it was indeed the issue with downto instead of to.

However I realized there is an easier way to do the thing I was looking for using the for loop.

set @len = indexOf ([listofemails],';')

 if @len > 0 then
   set @parts = BuildRowsetFromString ([listofemails],';')

   for @counter = 1 to RowCount(@parts) do
     set @part = row (@parts,@counter)
   next @counter

 endif

Many thanks,
Nikhil

1

I believe if you are doing a 'countdown' approach in a for statement (e.g. for @HIGHER to @LOWER) then you need to use 'DOWNTO' instead of 'TO'

The TO or DOWNTO keywords determine whether the value of the variable increases or decreases by one (1) with each iteration of the FOR loop. The variable value sets or increments by one (1) at the end of each iteration of the loop. The system compares the end index expression to the new value of the counter variable. If the value did not yet reach the end value or did not equal the end value, the loop will continue.

ex:

 set @len = indexOf ([listofemails],';')
        if @len > 0 then
            for @part = indexof([listofemails],';') downto 0 do
                @remainder = Add (@remainder,@ONE)
                /* script to update listofemails here*/
            next @part
        endif
0

Thanks @Gortonington

It was indeed the issue with downto instead of to. However I realized there is an easier way to do the thing I was lookig for using the for loop.

set @len = indexOf ([CCORGOPERATIONALCONTACTS],';') if @len > 0 then set @parts = BuildRowsetFromString ([CCORGOPERATIONALCONTACTS],';') for @counter = 1 to RowCount (@parts) do set @part = row (@parts,@counter)
next @counter endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.