Key Pages: [ Rope Home Page | Basics (tutorial) | Language Reference | Download ]
The "eval" action executes a block, and "catches" and returns it's exit status. The synax is one of..
eval( { block } )
{ block } eval
Possible returned statuses are..
Note that the capitalised words OKAY, FAIL, YES and NO are treated by the compiler as integer constants, and can be used directly in scripts to have the meanings described above. For example..
println( YES " - " NO )
prints: "2 - 3"
The following script will abort with a "EDivideByZero" error..
put( 20 $b ) put( 0 $z ) println( $b $z div )
However, the following script does not abort, but simply prints the number 0 (meaning FAIL).
eval({
put( 20 $b )
put( 0 $z )
println( $b $z div )
}) println
The following script exits, returning a "no" status for non-HTTP transfers
put( $data_start $offset ) expect_str( "GET /" )
By using the "eval" action, we can capture the "no" return rather than aborting, and then carry on executing..
eval({
put( $data_start $offset )
expect_str( "GET /" )
}) $s put
ifelse( eq( $s NO ) ) {
println( "Not an HTTP transfer" )
} {
println( "HTTP transfer detected" )
})
The "eval" action was added to Rope in the 20051212 release.
Lowth.com: [ Home | Rope | P2PWall | LinWiz | cutter | Protector - Free Antivirus software | TapeIO ]