GROOVY Procedure
Example: Define Classes
Features: |
- PROC GROOVY statement option:
- CLASSPATH
SUBMIT command option: PARSEONLY
SUBMIT command
ENDSUBMIT command
|
The following three
examples show how to use PROC GROOVY to define a class.
Program
Groovy code is run
by default. If your script does not have any executable code, then
an error is returned. The following example defines a class, but it
does not have any executable code, and an error is returned.
proc groovy classpath=cp;
submit;
class Speaker {
def say( word ) {
println "----> \"${word}\""
}
}
endsubmit;
quit;
Program
The following example
shows how to define a class that can be run by including a
main
method.
proc groovy classpath=cp;
submit;
class Speaker {
def Speaker() {
println "----> ctor"
}
def main( args ) {
println "----> main"
}
}
endsubmit;
quit;
Program
The following example
shows how to use the PARSEONLY option to avoid a run call. You can
then use the new class in another execution of PROC GROOVY.
proc groovy classpath=cp;
submit parseonly;
class Speaker {
def say( word ) {
println "----> \"${word}\""
}
}
endsubmit;
quit;
proc groovy classpath=cp;
eval "s = new Speaker(); s.say( ""Hi"" )";
quit;
Copyright © SAS Institute Inc. All rights reserved.