7
def var cList as char no-undo.
assign cList = "one,two,three,four".
<Loop> cList
logic...
</Loop>

在 char 变量中循环以逗号分隔的列表的最佳方法是什么,这样在这个例子中我会得到一个然后是两个然后是三个然后是四个。

4

3 回答 3

5

大声笑我仍然记得我认为的一些进步。

DEF VAR i AS INT NO-UNDO.
&SCOPED-DEFINE LIST "one,two,three,four"

DO i=1 TO NUM-ENTRIES({&LIST}):
  MESSAGE SUBSTITUTE("LIST[&1] is &2", i, ENTRY(i, {&LIST})).
END.
于 2012-04-03T13:59:52.757 回答
4
DEFINE VARIABLE ch-list     AS CHARACTER    NO-UNDO.
DEFINE VARIABLE i-cnt       AS INTEGER      NO-UNDO.
DEFINE VARIABLE i-entry     AS INTEGER      NO-UNDO.

ASSIGN
    ch-list = "one,two,three,four"
    .

ASSIGN
    i-cnt = NUM-ENTRIES(ch-list)
    .

REPEAT i-entry = 1 TO i-cnt:

    DISPLAY
        ENTRY(i-entry, ch-list)
        WITH DOWN.

END.
于 2012-04-03T13:56:49.560 回答
0
 DEFINE VARIABLE iNumEntries AS INTEGER NO-UNDO.

 DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.

 def var cList as char no-undo.

 assign cList = "one,two,three,four".

 ASSIGN iNumEntries = NUM-ENTRIES(cList,",").

 DO iLoop = 1 TO iNumEntries:

      MESSAGE ENTRY(iLoop,cList,",") VIEW-AS ALERT-BOX.

      /* You can use display, assign to variable, etc */

 END.
于 2015-08-27T09:48:21.983 回答