ARSperl
view release on metacpan or search on metacpan
example/Show_ALink.pl view on Meta::CPAN
#!/usr/local/bin/perl
#
# $Header: /cvsroot/arsperl/ARSperl/example/Show_ALink.pl,v 1.6 2000/06/01 16:54:03 jcmurphy Exp $
#
# EXAMPLE
# Show_ALink.pl
#
# DESCRIPTION
# Use ars_GetActiveLink to obtain information about an active link.
#
# NOTES
# This is a fairly large and involved example, however it illustrates
# many points about how to decode the more complex information that
# can be passed back from the API.
#
# All structures demonstrated herein are documented in the usage.html
# documentation.
#
# This example file parse most (but not all) of the active links
# fields.
#
# AUTHOR
# jeff murphy
#
# 01/12/96
#
# $Log: Show_ALink.pl,v $
# Revision 1.6 2000/06/01 16:54:03 jcmurphy
# *** empty log message ***
#
# Revision 1.5 1998/09/14 17:41:05 jcmurphy
# added ChangeDiary decoding lines
#
# Revision 1.4 1998/09/11 17:49:47 jcmurphy
# updated EXECUTE_ON definitions
#
# Revision 1.3 1998/09/11 17:22:13 jcmurphy
# changed macroParms from array to hash since it is
# a hashref.
#
# Revision 1.2 1997/11/11 15:04:47 jcmurphy
# added qual decoding
#
# Revision 1.1 1996/11/21 20:13:55 jcmurphy
# Initial revision
#
#
use ARS;
$debug = 0;
require 'ars_QualDecode.pl';
@MessageTypes = ( "Note", "Warn", "Error" );
# Parse command line parameters
($server, $username, $password, $alink_name) = @ARGV;
if(!defined($alink_name)) {
print "usage: $0 [server] [username] [password] [alink name]\n";
exit 1;
}
$level = 0;
# SUBROUTINE
# printl
#
# DESCRIPTION
# prints the string after printing X number of tabs
sub printl {
my $t = shift;
my @s = @_;
if(defined($t)) {
for( ; $t > 0 ; $t--) {
print "\t";
}
print @s;
}
}
# SUBROUTINE
# DecodeExecMask
#
# DESCRIPTION
# Simple routine to return a string representing (in english)
# the execution mask value(s).
example/Show_ALink.pl view on Meta::CPAN
}
printl $t, "Macro Text :\n**START**\n$m->{macroText}\n**END**\n";
}
}
# SUBROUTINE
# ProcessActions
#
# DESCRIPTION
# this routine processes the list of actions for this active link,
# deciding what actions are defined and dumping the appropriate
# information.
sub ProcessActions {
my @actions = @_;
if(defined(@actions)) {
$act_num = 1;
foreach $action (@actions) {
printl 1, "Action $act_num:\n";
if(defined($action->{macro})) {
printl 2, "Macro:\n";
ProcessMacroStruct(3, $action->{macro});
}
if(defined($action->{assign_fields})) {
printl 2, "Set Fields:\n";
foreach $setFields (@{$action->{assign_fields}}) {
printl 3, "fieldId: $setFields->{fieldId}\n";
ProcessSetFields($setFields->{assignment});
}
}
if(defined($action->{message})) {
printl 2, "Message: \n";
foreach my $k (keys %{$action->{message}}) {
printl 3, "$k: $action->{'message'}->{$k}\n";
}
}
if(defined($action->{process})) {
printl 2, "Process: ".$action->{process}."\n";
}
if(defined($action->{characteristics})) {
printl 2, "Change Field: ".$action->{characteristics}."\n";
}
if(defined($action->{dde})) {
printl 2, "DDE is not implemented in ARSperl.\n";
}
if(defined($action->{none})) {
printl 2, "No actions specified.\n";
}
$act_num++;
}
print "\n";
} else {
print "No actions to process!\n";
}
}
# Log onto the ars server specified
($ctrl = ars_Login($server, $username, $password)) ||
die "can't login to the server";
# Retrieve info about active link.
($a = ars_GetActiveLink($ctrl, $alink_name)) ||
die "can't fetch info about that active link";
print "Active Link Attributes:\n\n";
print "Name: ".$a->{name}."\n";
print "Execution Order: ".$a->{order}."\n";
if(defined($a->{'schema'})) {
print "Schema Name: ".$a->{schema}."\n";
} elsif(defined($a->{'schemaList'})) {
print "schemaList : ";
foreach my $s (@{$a->{'schemaList'}}) {
print "\"$s\" ";
}
print "\n";
}
print "Group Perms: ";
foreach $group (@{$a->{groupList}}) {
print "$group; ";
}
print "\n";
# XXX - decode
print "Execute On: ".DecodeExecMask($a->{executeMask})."\n";
print "Field: ".$a->{field}."\n"; # XXX - display only when needed (execmask)
print "Display List:\n";
foreach $display (@{$a->{displayList}}) {
printl 1, "Display Name: ".$display->{displayTag}."\n";
printl 2, "x corrd: ".$display->{x}."\n";
printl 2, "y coord: ".$display->{y}."\n";
printl 2, "Visible?: ".$display->{option}."\n";
printl 2, "Button Label: ".$display->{label}."\n";
printl 2, "Type: ".$display->{type}."\n";
}
print "\n";
#print "Qualification: ".$a->{query}."\n";
$dq = ars_perl_qualifier($ctrl, $a->{query});
$dq = undef if(isempty($dq));
if(defined($dq)) {
if(defined($a->{'schema'})) {
$dq_text = ars_Decode_QualHash($ctrl, $a->{schema}, $dq);
print " Qual Text: $dq_text\n";
}
elsif(defined($a->{'schemaList'})) {
foreach my $s (@{$a->{'schemaList'}}) {
$dq_text = ars_Decode_QualHash($ctrl, $s, $dq);
print " Qual Text (decoded against \"$s\": $dq_text\n";
}
}
} else {
print " Qual Text: [none defined]\n";
( run in 0.664 second using v1.01-cache-2.11-cpan-97f6503c9c8 )