#!/usr/local/bin/perl
(
$server
,
$username
,
$password
) = (
shift
,
shift
,
shift
);
if
(
$password
eq
""
) {
print
"Usage: $0 [server] [username] [password]\n"
;
exit
0;
}
$schema
=
"User"
;
$login_name
=
"Login name"
;
$lic_type
=
"License Type"
;
(
$ctrl
= ars_Login(
$server
,
$username
,
$password
)) ||
die
"ars_Login failed: $ars_errstr"
;
(
%fids
= ars_GetFieldTable(
$ctrl
,
$schema
)) ||
die
"ars_GetFieldTable: $ars_errstr"
;
$login_name
=
"Login Name"
if
(!
defined
(
$fids
{
$login_name
}));
(
$qual
= ars_LoadQualifier(
$ctrl
,
$schema
,
"(1 = 1)"
)) ||
die
"ars_LoadQualifier: $ars_errstr"
;
print
"Testing: basic format.\n"
;
(
@entries
= ars_GetListEntry(
$ctrl
,
$schema
,
$qual
, 0)) ||
die
"ars_GetListEntry: $ars_errstr"
;
for
(
$i
= 0;
$i
<
$#entries
;
$i
+=2) {
printf
(
"%s %s\n"
,
$entries
[
$i
],
$entries
[
$i
+1]);
}
print
"Testing: basic + sorting format.\n"
;
(
@entries
= ars_GetListEntry(
$ctrl
,
$schema
,
$qual
, 0,
$fids
{
$lic_type
}, 1)) ||
die
"ars_GetListEntry: $ars_errstr"
;
for
(
$i
= 0;
$i
<
$#entries
;
$i
+=2) {
printf
(
"%s %s\n"
,
$entries
[
$i
],
$entries
[
$i
+1]);
}
print
"Testing: basic + sorting + custom field-list format.\n"
;
if
(!
defined
(
$fids
{
$login_name
}) || !
defined
(
$fids
{
$lic_type
})) {
print
"Sorry. Either i can't find the field-id for \"$login_name\" or \"$lic_type\"\n on your \"$schema\" form. I'm skipping this test.\n"
;
}
else
{
(
@entries
= ars_GetListEntry(
$ctrl
,
$schema
,
$qual
, 0,
[ {
columnWidth
=> 15,
separator
=>
' '
,
fieldId
=>
$fids
{
$login_name
} },
{
columnWidth
=> 10,
separator
=>
' '
,
fieldId
=>
$fids
{
$lic_type
} }
],
$fids
{
$login_name
}, 1)) ||
die
"ars_GetListEntry: $ars_errstr"
;
for
(
$i
= 0;
$i
<
$#entries
;
$i
+=2) {
printf
(
"%s %s\n"
,
$entries
[
$i
],
$entries
[
$i
+1]);
}
}
ars_Logoff(
$ctrl
);
exit
0;