Re: Sort option of ars_GetListEntry
Brought to you by:
jeffmurphy
|
From: Vern H. <ve...@ey...> - 1996-05-12 03:24:55
|
On Sat, 11 May 1996, Bruce Friedman wrote:
>
> I've been trying to get the sort option to work in the
> ars_GetListEntry function, but have been unsuccessful. I've tried
> the example as in the 'usage' html page for ARSperl and ARSweb, but
> that doesn't seem to work for me. As I am *not* a very experienced
> perl programmer, I'm figuring it is something that I'm doing incorrectly.
> Basically, the example I'm trying to get to work looks like this:
>
> $sort_string->{numItems}=1;
> $sort_string->{sortList}[0]{fieldId}=2;
> $sort_string->{sortList}[0]{sortOrder}=1;
> %entries =
> ars_GetListEntry($ctrl, $schema, $qual, $max_records, %sort_string);
>
> This example should return the field-id and quick list description from my
> schema sorted by field-id 2, but it doesn't. I've also tried reversing
> '$max_records' and '%sort_string' since I wasn't sure about the order,
> however that didn't work either. Also, are multiple sort fields allowed?
>
> Anyone who can give me some quick pointers on how to get this to work?
The problem you are running into is probably due to the fact that
the perl functions keys(), values(), and each() return then entries
of an associative array in seemingly random order.
I've just done some experimenting with using @entries instead of
%entries and that seems to work:
@entries = ars_GetListEntry($ctrl, $schema, $qualif, 0,
$IPriority, 1, # sort by priority (ascending)
$IIncidnetOwner, 1, # sort by owner (ascending)
);
for ($i=0; $i<$#entries; $i+=2)
{
printf("%d %s\n", $entries[$i], $entries[$i+1]);
}
This sorts first by fieldId $IPriority and then $IIncidnetOwner,
both in ascending order. Then you have to use a for loop to
step through the entries. (An associative array is just a
normal array with the elements paired, or associated.) The for
loop I have above would have the associative equivalent of:
foreach $entry (keys(%entries))
{
printf("%d %s\n", $entry, $entries{$entry});
}
Oh, and by the way, you misspelled m-e-n-t-o-s.
Hope this helps!
Vern
--
,+'^'+,
Vern Hart O Creative Design Engineer - Hungry Programmers
`+,.,+' ve...@hu... http://www.hungry.com
Mountains of Silly Putty! - http://www.sirds.com/sillyputty
|