/* This trivial example prints the total length /* of the arcs in coverage %cov% /* Run from ArcEdit &s cov roads edit %cov% arc sel all &s tmpfile1 [scratchname -prefix xxtmp1 -file] &s tmpfile2 [scratchname -prefix xxtmp2 -file] /* Send the results of our list command to %tmpfile1% apc listoutput %tmpfile1% list length /* Restore the list command apc listoutput screen &sys perl -x%aml$file% %tmpfile1% %tmpfile2% /* Execute the file created by our Perl program, /* which sets the global variable .totlength &r %tmpfile2% /* Clean up a bit... &s x [delete %tmpfile1% -file] &s x [delete %tmpfile2% -file] re %cov% y /* Now print our result! &ty The total length of the arcs in %cov% is %.totlength% &return /* End thread of AML execution before we hit Perl code... /*** Our embedded Perl program follows #!perl # Set $in to %tmpfile1% and $out to %tmpfile2% # @ARGV is an array holding the parameters we passed ($in,$out)=@ARGV; open(IN,"<$in") || die "Could not open input file $in: $!\n"; open(OUT,">$out") || die "Could not open output file $out: $!\n"; $totlength=0; ; # Skip the first line, which is the column header # Read each data record the file while() { # Split the record into two fields ($recno,$length)=split; $totlength+=$length; } # Create a single-line AML file that sets the global # variable .totlength to the results of our calculation print OUT "&s .totlength $totlength\n";