Array Question

mwoudszer

New Member
Alright here's my code:

IF LASTKEY EQ KEYCODE("return") THEN
DO:
IF wfield_order[frame-index] EQ 0 THEN
DO:
wfield_order[frame-index] = i.
i = i + 1.
DISPLAY wfield_order[frame-index] WITH FRAME wfield_choice.
END.
ELSE IF wfield_order[frame-index] NE 0 THEN
DO:
wsave = wfield_order[frame-index].
wfield_order[frame-index] = 0.
DISPLAY wfield_order[frame-index] WITH FRAME wfield_choice.
i = i - 1.
REPEAT j = 1 to 22:
IF wfield_order[j] GT wsave THEN
DO:
wfield_order[j] = wfield_order[j] - 1.
i = wfield_order[j] + 1.
END.
END.
END.
END.
END.

REPEAT I=1 TO 22:
IF wfield_order NE 0 THEN
wfhdr[wfield_order]=wfields.
END.

****************************************************
What I'm trying to do is:
I have a list of items which are put into the array:

item one
item two
item three
...

The user should be able to select the order in which to display the items:

item one 1
item two 2
item three 3
... 4

If the user decides to change the order the numbers should fix themselves accordingly:

item one 1
item two <-------user changes this to zero by pressing return
item three 3 <-------this number should automatically go to 2
... 4 <-------this number should automatically go to 3

Any ideas?

Thanks,
Matt
 
nevermind fixed it

fixed it...here's the fixed code:

IF wfield_order[frame-index] EQ 0 THEN
DO:
wfield_order[frame-index] = i.
i = i + 1.
DISPLAY wfield_order[frame-index] WITH FRAME wfield_choice.
END.
ELSE IF wfield_order[frame-index] NE 0 THEN
DO:
wsave = wfield_order[frame-index].
wfield_order[frame-index] = 0.
DISPLAY wfield_order[frame-index] WITH FRAME wfield_choice.
i = i - 1.
REPEAT j = 1 to 22:
IF wfield_order[j] GT wsave THEN
DO:
wfield_order[j] = wfield_order[j] - 1.
DISPLAY wfield_order[j] WITH FRAME wfield_choice.
END.
END.


thanks anyways...
 
Back
Top