the list. For example, consider a workflow application with approval cycle.
Let's say three approvers are there and you want user to define the order. The
following code shows how you can allow the user to define the order.
1. Create a form and type @Command([ViewRefreshFields]) in the PostOpenEvent
of the form.
2. Create a layout region and check both "Show Border" and "3D Style".
3. Create a field (in layout region) called "Fld1" as Keywords, Editable,
select "Use Formula for choices" from choices
combo box and enter value as "Fld2" and select List Box from Interface (expand
the list box to hold three values).
4. Create another field (in layout region) called "Fld2" as Text, Editable,
check "Allow multi-values", and delimiter as Newline. Hide the field for both
read and write mode. Now, enter the value
"ApproverOne":"ApproverTwo":"ApproverThree" in the default value of the field.
5. Create a hotspot button (in layout region) called "Up" and type the
following formula.
tmp:=fld1;
max:=@Elements(fld2);
tmp1:=@Member(tmp;fld2);
tmp2:="";
tmp3:="";
tmp4:="";
tmp5:="";
@If((tmp1-2)>0;@Set("tmp2";@Subset(fld2;(tmp1-2)));@Set("tmp2";""));
@If((tmp1-1)>0;@Set("tmp3";@Subset(@Subset(fld2;(tmp1-1));-1));@Set("tmp3";""));
@If(tmp1>0;@Set("tmp4";@Subset(@Subset(fld2;tmp1);-1));@Set("tmp4";""));
@If((max-tmp1)>0;@Set("tmp5";@Subset(fld2;(tmp1-max)));@Set("tmp5";""));
FIELD fld2:=tmp2:tmp4:tmp3:tmp5;
FIELD fld1:=tmp;
@Command([ViewRefreshFields])
6. Create another hotspot button (in layout region) called "Down" and type the
following formula.
(fld2);
tmp1:=@Member(tmp;fld2);
tmp2:="";
tmp3:="";
tmp4:="";
tmp5:="";
@If((tmp1-1)>0;@Set("tmp2";@Subset(fld2;(tmp1-1)));@Set("tmp2";""));
@If((tmp1)>0;@Set("tmp3";@Subset(@Subset(fld2;(tmp1));-1));@Set("tmp3";""));
@If(tmp1=max;@Set("tmp4";"");(tmp1+1)>0;@Set("tmp4";@Subset(@Subset(fld2;
(tmp1+1));-1));@Set("tmp4";""));
@If((max-(tmp1+1))>0;@Set("tmp5";@Subset(fld2;((tmp1+1)-max)));@Set("tmp5";""));
FIELD fld2:=tmp2:tmp4:tmp3:tmp5;
FIELD fld1:=tmp;
@Command([ViewRefreshFields])
7. Save the form as "UserSort" and execute it. Select the choice in the list
and click up or down button to move the item. The user defined order is
readily available in the field "Fld2".
Note: I've entered a default value in "Fld2" instead you can pass your own
value during run-time whereby user can define their own order of your choices.
Hope this helps.
This was first published in November 2000