I have been struggling with a method which was sometimes functioning and sometimes not until I discovered that, if the last function was in the last line of the method, it was not executed. Adding any text (eg var z = 0;) resolved the issue.
var intCom = “SELECT tb_comuneid, fd_com_comune FROM tb_comune WHERE fd_com_prov_istat = “+cercaProv+” ORDER BY tb_comuneid”;
var maxReturnedRows = 1500;
var datasetCom = databaseManager.getDataSetByQuery(controller.getServerName(), intCom, null, maxReturnedRows);
var arrComId = datasetCom.getColumnAsArray(1);
var arrComCom = datasetCom.getColumnAsArray(2);
The line
var arrComCom = datasetCom.getColumnAsArray(2);
was not executed if it was the last on.
I remember reading a post about something similar, but I could not find it. Did I make any mistake or is this a bug? Thanks
I find that a strange last line for a method. What do you want to do? When your method is done your var’s no longer exist so asigning something to a var as a last line really doesn’t make any sense.
Last line of a method is always executed. If you are stepping with debugger it can be handy to create one fake line below so you can see what happened after execution of your real last line inside the debugger.
You are perfectly right, but I isolated this part of the code from a longer method just to test it and I did not understand why I could not get the results for the second array. Do you mean that Servoy is so clever to understand that the code will be useless and therefore it doesn’t execute it? But, yes, I executed it in the debugger and this explains everything.
The problem is, that you don’t see how the last step is executed in the debugger. That is why Jan suggested to add a dummy line so you can see the result in the debugger.