I am having problems with the bottom portion of this formula that prints out the elements in the array. This array is suppose to sort the elements, but it does not appear it is doing that. When I print out element1, element2, etc, I do not see them in sorted order --any ideas?
whileprintingrecords;
numbervar x :=1;
numbervar y :=1;
stringvar array PopD;
redim POPD[8];
stringvar temp;
stringvar element1;
stringvar element2;
stringvar element3;
stringvar element4;
stringvar element5;
stringvar element6;
stringvar element7;
stringvar element8;
if not isnull({POPULATION_DISPLAY.FULL_NAME_SORT}) then
PopD [1] := totext({POPULATION_DISPLAY.FULL_NAME_SORT})
else
popd [1] :='0';
if not isnull({POPULATION_DISPLAY.USER_NUMBER_SORT}) then
PopD [2] := totext({POPULATION_DISPLAY.USER_NUMBER_SORT})
else
POPd [2] := '0';
if not isnull({POPULATION_DISPLAY.EMAIL_WORK_SORT}) then
PopD [3] := totext({POPULATION_DISPLAY.EMAIL_WORK_SORT})
else
POPd [3] :='0';
if not isnull({POPULATION_DISPLAY.DIVISION_SORT}) then
PopD [4] := totext({POPULATION_DISPLAY.DIVISION_SORT})
else
POPD[4] :='0';
if not isnull({POPULATION_DISPLAY.OPERATING_UNIT_SORT}) then
PopD [5] := totext({POPULATION_DISPLAY.OPERATING_UNIT_SORT})
else
POPD [5] :='0';
if not isnull({POPULATION_DISPLAY.COUNTRY_NAME_SORT})then
PopD [6] := totext({POPULATION_DISPLAY.COUNTRY_NAME_SORT})
else
POPD [6] :='0';
if not isnull({POPULATION_DISPLAY.ADT_US_WORK_LOCATION_CODE_S})then
PopD [7] := totext({POPULATION_DISPLAY.ADT_US_WORK_LOCATION_CODE_S})
else
popd [7] :='0';
if not isnull({POPULATION_DISPLAY.TSP_SBU_SORT}) then
PopD [8] := totext({POPULATION_DISPLAY.DEPARTMENT_SORT})
else
POPD [8] :='0';
for x := 1 to 6 do
(
for y := 1 to 5 do
(
if PopD[y] > PopD[y+1] then
(
temp := PopD[y];
PopD[y] := PopD[y + 1];
PopD[y + 1] := temp;
);
// y := Y + 1;
);
//x := x + 1;
);
element1:= popd[1];
element2:= popd[2];
element3:= popd[3];
element4:= popd[4];
element5:= popd[5];
element6:= popd[6];
element7:= popd[7];
element8:= popd[8];
whileprintingrecords;
numbervar x :=1;
numbervar y :=1;
stringvar array PopD;
redim POPD[8];
stringvar temp;
stringvar element1;
stringvar element2;
stringvar element3;
stringvar element4;
stringvar element5;
stringvar element6;
stringvar element7;
stringvar element8;
if not isnull({POPULATION_DISPLAY.FULL_NAME_SORT}) then
PopD [1] := totext({POPULATION_DISPLAY.FULL_NAME_SORT})
else
popd [1] :='0';
if not isnull({POPULATION_DISPLAY.USER_NUMBER_SORT}) then
PopD [2] := totext({POPULATION_DISPLAY.USER_NUMBER_SORT})
else
POPd [2] := '0';
if not isnull({POPULATION_DISPLAY.EMAIL_WORK_SORT}) then
PopD [3] := totext({POPULATION_DISPLAY.EMAIL_WORK_SORT})
else
POPd [3] :='0';
if not isnull({POPULATION_DISPLAY.DIVISION_SORT}) then
PopD [4] := totext({POPULATION_DISPLAY.DIVISION_SORT})
else
POPD[4] :='0';
if not isnull({POPULATION_DISPLAY.OPERATING_UNIT_SORT}) then
PopD [5] := totext({POPULATION_DISPLAY.OPERATING_UNIT_SORT})
else
POPD [5] :='0';
if not isnull({POPULATION_DISPLAY.COUNTRY_NAME_SORT})then
PopD [6] := totext({POPULATION_DISPLAY.COUNTRY_NAME_SORT})
else
POPD [6] :='0';
if not isnull({POPULATION_DISPLAY.ADT_US_WORK_LOCATION_CODE_S})then
PopD [7] := totext({POPULATION_DISPLAY.ADT_US_WORK_LOCATION_CODE_S})
else
popd [7] :='0';
if not isnull({POPULATION_DISPLAY.TSP_SBU_SORT}) then
PopD [8] := totext({POPULATION_DISPLAY.DEPARTMENT_SORT})
else
POPD [8] :='0';
for x := 1 to 6 do
(
for y := 1 to 5 do
(
if PopD[y] > PopD[y+1] then
(
temp := PopD[y];
PopD[y] := PopD[y + 1];
PopD[y + 1] := temp;
);
// y := Y + 1;
);
//x := x + 1;
);
element1:= popd[1];
element2:= popd[2];
element3:= popd[3];
element4:= popd[4];
element5:= popd[5];
element6:= popd[6];
element7:= popd[7];
element8:= popd[8];