I feel this is something I did years ago but can’t seem to find the Servoy little function. I know I can turn say a dataset.getColumnAsArray(1) that looks like this ‘[123, 456, 678]’ into this ‘123, 456, 678’ with regex or array.shift stuff but I thought there was some simple Servoy function that made it even easier. I’m going to have to do this a lot (basically passing various ‘IDs’ to ‘IN’ statements) to simplify some queries against our huge hospital database and thought I’d ask…
Array.join(separator) is what you are looking for…
So you can do:
var ids = dataset.getColumnAsArray(1).join(',');
Hope this helps,
Thanks Patrick. That’s strange. That’s what I thought it was, the join function. But when I did it to populate the IN statement it still failed and when I outputted the result it still had the square brackets surrounding it like an array. I did it in two lines getting the dataset column as an array and then doing the join with separator statement but I think pretty much the same thing. I’ll try tomorrow. You don’t get the square brackets with that? (Servoy 6.1.3)
John
var array = [123, 456, 678];
application.output(array.join(','));
Gives me:
123,456,678
So I don’t know what you are doing but probably something wrong!
Yup. Definitely something wrong. I tried doing ‘undo’ as far as I could to see how I phrased it but wouldn’t go back that far. I hadn’t used join in a long while but it is such a simple array function I can’t see how I could have had it wrong. Must have grabbed the wrong variable to output and put in the IN clause I guess…
Thanks Patrick!