[COLOR=#0000ff]PROCEDURE [/COLOR]last-views:
[COLOR=#0000ff]DEF VAR[/COLOR] jj [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF VAR [/COLOR]aa [COLOR=#0000ff]AS INT[/COLOR].
jj = browse-name:NUM-[COLOR=#0000ff]COLUMNS
[/COLOR][COLOR=#000000]aa = 1.[/COLOR]
[COLOR=#0000ff]IF [/COLOR]field-01 will be shown at the end of the browse [COLOR=#0000ff]THEN DO[/COLOR]:
[COLOR=#0000ff]CREATE [/COLOR]temp-table-2.
[COLOR=#0000ff]ASSIGN [/COLOR]
temp-table-2.col-name = field-01
temp-table-2.col-order = jj.
jj = jj - 1.
[COLOR=#0000ff]END.
END[/COLOR].
[COLOR=#0000ff]IF [/COLOR]field-01 will be shown at the beginning of the browse [COLOR=#0000ff]THEN DO[/COLOR]:
[COLOR=#0000ff]CREATE [/COLOR]temp-table-2.
[COLOR=#0000ff]ASSIGN [/COLOR]
temp-table-2.col-name = field-01
temp-table-2.col-order = aa.
aa = aa + 1.
[COLOR=#0000ff]END[/COLOR].
/* The below code is set the our last view as the first view for the next arrangements of the browse view.
It moves the columns by comparing the first view and last view.
At the end of the procedure we empty temp-table "temp-table-2" for reseting last view positions in the browse
*/
[COLOR=#0000ff]DEF VAR [/COLOR]old-pos [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF VAR[/COLOR] new-pos [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF VAR[/COLOR] cc [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF BUFFER[/COLOR] btemp-table-1 [COLOR=#0000ff]FOR [/COLOR]temp-table-1.
[COLOR=#0000ff]DO [/COLOR]cc = 1 [COLOR=#0000ff]TO [/COLOR]browse-name:[COLOR=#0000ff]NUM-COLUMNS[/COLOR]:
new-pos = cc.
[COLOR=#0000ff]FIND FIRST [/COLOR]temp-table-2
[COLOR=#0000ff]WHERE[/COLOR] temp-table-2.col-order [COLOR=#0000ff]EQ[/COLOR] cc [COLOR=#0000ff]NO-ERROR[/COLOR].
[COLOR=#0000ff]IF NOT AVAILABLE [/COLOR]temp-table-2 [COLOR=#0000ff]THEN NEXT[/COLOR].
[COLOR=#0000ff]FIND FIRST [/COLOR]temp-table-1
[COLOR=#0000ff]WHERE[/COLOR] temp-table-1.col-name [COLOR=#0000ff]EQ[/COLOR] temp-table-2.col-name [COLOR=#0000ff]NO-ERROR[/COLOR].
old-pos = temp-table-1.col-order.
[COLOR=#0000ff]IF[/COLOR] temp-table-1.col-order [COLOR=#0000ff]EQ [/COLOR]temp-table-2.col-order [COLOR=#0000ff]THEN NEXT.
[/COLOR][COLOR=#0000ff] IF [/COLOR]temp-table-1.col-order [COLOR=#0000ff]NE [/COLOR]temp-table-2.col-order [COLOR=#0000ff]THEN DO[/COLOR]:
[COLOR=#0000ff]BROWSE [/COLOR]browse-name:[COLOR=#0000ff]MOVE-COLUMN[/COLOR](old-pos,new-pos).
[COLOR=#0000ff]FOR EACH [/COLOR]btemp-table-1
[COLOR=#0000ff]WHERE[/COLOR] btemp-table-1.col-order [COLOR=#0000ff]GE[/COLOR] new-pos
[COLOR=#0000ff]USE-INDEX [/COLOR]order-ndx:
[COLOR=#0000ff]IF[/COLOR] btemp-table-1.moved [COLOR=#0000ff]EQ[/COLOR] 1 [COLOR=#0000ff]THEN NEXT.
[/COLOR] [COLOR=#0000ff]IF [/COLOR]btemp-table-1.col-order [COLOR=#0000ff]GE [/COLOR]old-pos [COLOR=#0000ff]THEN LEAVE[/COLOR].
[COLOR=#0000ff]IF [/COLOR]btemp-table-1.col-order [COLOR=#0000ff]EQ [/COLOR]browse-name:[COLOR=#0000ff]NUM-COLUMNS [/COLOR][COLOR=#0000ff]THEN LEAVE[/COLOR].
btemp-table-1.col-order = btemp-table-1.col-order + 1.
btemp-table-1.moved = 1.
[COLOR=#0000ff]END[/COLOR].
temp-table-1.col-order = temp-table-2.col-order.
[COLOR=#0000ff]END.
FOR EACH [/COLOR]temp-table-1:
temp-table-1.moved = 0.[COLOR=#0000ff]
END.
END.
EMPTY TEMP-TABLE [/COLOR]temp-table-2[COLOR=#0000ff].
END PROCEDURE.
[/COLOR]