ARSperl

 view release on metacpan or  search on metacpan

example/Show_ALink.pl  view on Meta::CPAN



# 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).

$AR_EXECUTE_ON_NONE          = 0;
$AR_EXECUTE_ON_BUTTON        = 1;
$AR_EXECUTE_ON_RETURN        = 2;
$AR_EXECUTE_ON_SUBMIT        = 4;
$AR_EXECUTE_ON_MODIFY        = 8;
$AR_EXECUTE_ON_DISPLAY       = 16;
$AR_EXECUTE_ON_MODIFY_ALL    = 32;
$AR_EXECUTE_ON_MENU          = 64;
$AR_EXECUTE_ON_MENU_CHOICE   = 128;
$AR_EXECUTE_ON_LOOSE_FOCUS   = 256;
$AR_EXECUTE_ON_SET_DEFAULT   = 512;
$AR_EXECUTE_ON_QUERY         = 1024;
$AR_EXECUTE_ON_AFTER_MODIFY  = 2048;  # Added in 3.2
$AR_EXECUTE_ON_AFTER_SUBMIT  = 4096;
$AR_EXECUTE_ON_GAIN_FOCUS    = 8192;
$AR_EXECUTE_ON_WINDOW_OPEN   = 16384;
$AR_EXECUTE_ON_WINDOW_CLOSE  = 32768;

%ars_ExecuteOn = ($AR_EXECUTE_ON_BUTTON, "Button", 
    $AR_EXECUTE_ON_RETURN,        "Return",
    $AR_EXECUTE_ON_SUBMIT,        "Submit",
    $AR_EXECUTE_ON_MODIFY,        "Modify",
    $AR_EXECUTE_ON_DISPLAY,       "Display", 
    $AR_EXECUTE_ON_MENU,          "Menu", 
    $AR_EXECUTE_ON_MENU_CHOICE,   "Menu_Choice", 
    $AR_EXECUTE_ON_LOOSE_FOCUS,   "Loose_Focus", 
    $AR_EXECUTE_ON_SET_DEFAULT,   "Set_Default",
    $AR_EXECUTE_ON_QUERY,         "Query",
    $AR_EXECUTE_ON_AFTER_MODIFY,  "After_Modify",
    $AR_EXECUTE_ON_AFTER_SUBMIT,  "After_Submit",
    $AR_EXECUTE_ON_GAIN_FOCUS,    "Gain_Focus",
    $AR_EXECUTE_ON_WINDOW_OPEN,   "Window_Open",
    $AR_EXECUTE_ON_WINDOW_CLOSE,  "Window_Close" 
		  );

sub DecodeExecMask {
    my $m = shift;
    my $s, $v;

    if(defined($m)) {
	foreach $v (sort keys %ars_ExecuteOn) {
	    if($v & $m) {
		$s = $s." ".$ars_ExecuteOn{$v};
	    }
	}
    }
    return($s);
}

# SUBROUTINE
#   PrintArith
#
# DESCRIPTION
#   Attempt to "pretty print" the arith expression (just for
#   the hell of it)
#
# NOTES
#   Notic that parenthesis are printed, although they are not
#   explicitly part of the node information. They are derived
#   from the ordering of the tree, instead. If you want to actually
#   *evaluate* the expression, you will have to derive the 
#   parenthetical encoding from the tree ordering.
#
#   Here is an example equation and how it is encoded:
#
#   ((10 + 2) / 3)
#
#          "/"
#         /   \
#       "+"    3
#      /  \
#    10    2
#
#   ARS apparently sorts the operations for you (based on their
#   mathematical precedence) so you should evaluate the tree from 
#   the bottom up. 
#
#   ars_web.cgi has an evaluation routine for computing the value
#   of a arith structure. we will probably break it out into a
#   perl module.
#
# THOUGHTS
#   I don't know if this routine will work for all cases.. but
#   i did some tests and it looked good. Ah.. i just wrote it
#   for the fun of it.. so who cares? :)



( run in 0.782 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )