MC Press Online Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Sorting Data Structures (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Sorting Data Structures
#121863
KimHansen (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
Sorting Data Structures 3 Months, 2 Weeks ago Karma: 0  
I'm sorry about the code below being wrapped on single lines... I can't get it to show differently... MC Press???

This thread discusses the Content article: Sorting Data Structures

I have a web application were I need to sort an array based on a data structure. The array should be sorted using the qsort function. My definitions looks like the following:
Code:

h bnddir('QC2LE')

d IFS_EntryDS ds
d Name 64a varying
d Attr 6a varying

d IFS ds qualified
d List likeds(IFS_EntryDS) dim(100)

d IFS_ListCount s 10i 0 inz(0)

d SortArrayQ pr extproc('qsort')
d base * value
d num 10u 0 value
d width 10u 0 value
d compare * procptr value

d SortCompare pr 10i 0
d parm1 * value
d parm2 * value

d i s 10i 0 inz(0)


and my SortCompare (I have removed the logic to keep the example short and this always returns 0 meaning no sort):
Code:

/end-free
p SortCompare b
d SortCompare pi 10i 0
d parm1 * value
d parm2 * value
/free
return 0;
/end-free
p e
/free


My main looks like the following:
Code:

IFS_ListCount = 5;
IFS.List(1).Name = 'Q1';
IFS.List(2).Name = 'c2';
IFS.List(3).Name = 'A3';
IFS.List(4).Name = 'a4';
IFS.List(5).Name = 'f5';

SortArrayQ(
%addr(IFS.List) :
IFS_ListCount :
%size(IFS_EntryDS) :
%paddr('SortCompare')
);

for i = 1 to IFS_ListCount;
// From here I should be able to work with:
// %trim(IFS.List(i).Name)
endfor;


The program compiles perfectly but never generates any output. If I comment out the SortArrayQ(...) statement then it generates the logic in the for-loop and returns content. I can't figure out why.... any ideas?
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/05/14 08:47 By KimHansen.
  The administrator has disabled public write access.
#121866
Tom Daly (User)
Fresh Boarder
Posts: 15
graphgraph
User Offline Click here to see the profile of this user
Re:Sorting Data Structures 3 Months, 2 Weeks ago Karma: 0  
Just a guess really, but make the subfields in IFS_EntryDS fixed length rather than varying.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
   MC-STORE.COM