Suggested answer

FOR @i = startValue TO endValue DO ... NEXT @i iterates a counter variable. The most common use is iterating over a LookupRows or LookupOrderedRows rowset:
%%[
SET @rows = LookupRows("Orders","Email",emailaddr)
SET @cnt = RowCount(@rows)
FOR @i = 1 TO @cnt DO
SET @row = Row(@rows, @i)
SET @product = Field(@row, "ProductName")
]%%
%%=@product=%%<br>
%%[ NEXT @i ]%%
Note that AMPscript does not support WHILE loops. All iteration must be done via FOR/NEXT with a known upper bound (use RowCount to get it).

Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.

Community comments (0)

No comments yet.

Sign in or create a free account to add a comment. Comments are moderated before they appear.

Plain text only, 3–2000 characters. A moderator reviews every comment before it is published.