Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing elements in an array sort

Status
Not open for further replies.

shircol

MIS
Jun 27, 2008
5
US
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];
 
The final line of the formula is what displays as the result. so you will see Element8 as the result.

Replace the element1:=popd[1]; and all the following lines with
Join (popd, ", ")

In fact you can remove all the references to element1, element2 and work directly with the popd array.

Editor and Publisher of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top