testdql(code,funcwhendone)

Parameters

- code the dql to test

- funcwhendone a function called when the results are ready from the dql test. It will need the format function(jdata) where jdata is the json returned from the test.

This function will take a page or pure dql code and test it for errors. If there are a error a errorno, errorpos and error will be returned. If no error the dql tdf will be returned that will give you a list of fields that can be used in the output.

How it is used in DQLEdit

// the button definition
$("#test").on('click',function(me){ 
  var elm=$("#dqlcontent");
  var code = elm.val();
  dec.testdql(code); 
});

// the message handler used if no funcwhendone is given
this.displaydqlerror=function(jdata){
    if (jdata.result == 'ok'){
        var dqldef = jdata.dqldefinition.default;
        _this.message('All ok','success');
    } else if (jdata.result == 'error'){
        var dqldef = jdata.dqldefinition.default;
        if (dqldef.errorno) { // We have an error
            var error = 'Error no: ('+dqldef.errorno+') '+dqldef.error+' at position: '+ dqldef.errorpos;
            _this.message(error,"error");
        }
    }    
}<br>

The default code in the editor