<<Is there an "elegant" way to do this with a simple array of values:
DECLARE CursorName CURSOR FOR (1,2,3,4,5)
... where we're stepping through the array WITHOUT drawing upon a source table?
>>
Is this expected to produce five iterations with one value each time, or one
iteration with five values?
If you want five iterations of the loop with one value each time, and the
values are guaranteed not to contain commas (which will be true if they're
numeric values) then you can do this:
SET VAR tList TEXT = ('1,2,3,4,5')SET VAR tIndex INT = 0
WHILE 1 = 1 THEN
SET VAR tIndex = (.tIndex + 1) SET VAR tTextTerm = (SSUB(.tList,
.tIndex)) IF tTextTerm IS NULL THEN BREAK ENDIF
-- Cast to appropriate type if not TEXT SET VAR tIntTerm INT =
(INT(.tTextTerm))
-- Meaningful code here
ENDWHILE
CLEAR VAR tList, tIndex, tTextTerm, tIntTermRETURN
You can construct more complex scenarios by pulling two or three terms off the
list for each iteration, or using a different character to separate fields and
records in the list. This is also suitable for use with LISTOF(), getting a
list of values from a table and then iterating over the list without the
cursor.--Larry <!--#yiv6753879002 body{font-family:'Segoe
UI';font-size:12pt;}-->
--
You received this message because you are subscribed to the Google Groups
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.