Scripting in the Charge Rule API
A charge rule scripting application programming interface (API) is available to users. Users write a JavaScript function that takes three parameters: a parameters object, a hole object and a built-in blast product object. The JavaScript function is called once for every hole the charge rule is applied to and is responsible for assigning a blast product for every part of the hole.
For example:
function rule(params, hole) {
hole.fill(hole.upper(hole.length*0.5), params.stemming);
var explosiveInterval = hole.unallocated();
if (!hole.params.water_condition){
hole.fill(explosiveInterval, params.explosive);
}
else {
hole.fill(explosiveInterval, params.stemming);
}
}
The JavaScript function contains a series of subfunctions which are associated with object interfaces and included in the API for you to use within the script. For a list of all the built-in functions and object interfaces, see the followings: