' Launch an instance of the ScriptControl Set objSC = CreateObject("ScriptControl") objSC.Language = "PerlScript" |
' Define the min_max function. objSC.addcode ( _ "sub min_max { " + vbCrLf + _ " # Get the arguments to this function " + vbCrLf + _ " my $args = shift; " + vbCrLf + _ " " + vbCrLf + _ " # Comma-delimited text into an array " + vbCrLf + _ " my @args = split(/,/, $args); " + vbCrLf + _ " " + vbCrLf + _ " # Sort the values numerically " + vbCrLf + _ " my @asc = sort { $a <=> $b } @args; " + vbCrLf + _ " " + vbCrLf + _ " # Get the first and last value " + vbCrLf + _ " my @result = ($asc[0], $asc[$#asc]); " + vbCrLf + _ " " + vbCrLf + _ " # Return an array reference " + vbCrLf + _ " return \@result; " + vbCrLf + _ "}") |
Forward to PerlScript Example: Command1_Click()
Back to Perl and ActiveX Up to PerlInside section index Up to Perl Inside course index |
Perl Inside: PerlInside - 25
Copyright © 1999, Brian Jepson
|