Use DSL constants inside procedure

I have some constants defined on the top of a rule file, and I wanted to be able to use them inside a procedure, like this:

val int POWERDOWN = 0

val Procedures$Procedure1 < String > p1 = [host |
    logInfo("EXEC","host=" + host + "->" + POWERDOWN)
]

However the above code evaluates POWERDOWN as null, and the only workaround is to declare the same constants inside the procedure.

Any way to do this?

Thanks.

Yes, pass them in as parameters when calling the procedure.

Also, that’s a really old and not very friendly way to define a procedure. Just use

val p1 = [ String host |
    logInfo("EXEC", ...
]

That’s all there is to it.

In my procedure I have multiple constants, and passing all of them will go beyond the argument limit of 6.

An error occurred during the script execution: Closures with more then 6 parameters are not supported.

Put them all in a Map object, and pass that in. Rather like the “array” of Timer references in the example.you looked at before.

That’s an excellent suggestion, since part of the parameters were the indexes of the Timers. Changing the timer list to a Map I ended up with a cleaner code.