Types of parameters for a private function


What types of parameters can be used for a private function?

text -> ok

number -> ok

array -> ?

record -> ?

date -> ?

table -> ?

and more?

Ninox Profile

Please someone reply to this. I'm also trying to create a function with an array parameter but dont know how

Ninox Profile

As far as I can tell the only data types you can use in a user-defined function are the following...


Number, Text, Date, Time and DateTime


If you try use array, you will get an "Unknown type" error like this...


Screen Shot 2018-12-14 at 6.57.06 PM

Ninox Profile

As long as an array is defined before the user-defined function, you can manipulate the array inside the function.


Screen Shot 2018-12-16 at 11.39.52 AM

Ninox Profile

So, I had some time to kill because the retards in Birmingham, Al closed two lanes of traffic on I-459 for road construction. They could have sent traffic through downtown this being a Sunday and all!!! Here's a version of a user-defined function that replaces a single array item...


let myArray := ["Python", "Ruby", "Java", "C++"];
function replaceArrayItem(indexItem: text, index: number) do
   switch index do
   case 0:
      myArray := [indexItem, item(myArray, 1), item(myArray, 2), item(myArray, 3)]
   case 1:
      myArray := [item(myArray, 0), indexItem, item(myArray, 2), item(myArray, 3)]
   case 2:
      myArray := [item(myArray, 0), item(myArray, 1), indexItem, item(myArray, 3)]
   case 3:
      myArray := [item(myArray, 0), item(myArray, 1), item(myArray, 2), indexItem]
replaceArrayItem("Swift", 3)


The screenshot cuts off some of the code...


Screen Shot 2018-12-16 at 2.23.48 PM

Ninox Profile

Ooops, to get the output...


replaceArrayItem("Swift", 3);



then click run


I can't remember where I first saw this, but functions can also accept and return 'boolean' as an argument type, as in:

function myfunc(arg: boolean) do
    if arg then bla bla bla end

Also, experimentation shows that functions can return more types than they can accept. For example, a function can actually return a record:

function getrecord(key : text) do
    first(select Locations where Location = key)


If you really need to pass an array into a function (e.g. into one of the new user-defined global functions), one approach I've used is to pass a string argument with a known convention for delimiting array values, then splitting that argument into its array elements inside the function (using the 'split' function).


function test(argstring : text) do
    let args := split(argstring, "|");


Of course, the usefulness of this depends upon whether you can settle on a delimiter that you know will NEVER be contained within an array element.

BTW, a user-defined function can RETURN an array:


function createarray(arraystring : text) do
    split(arraystring, ", ")
let array := createarray('Array In')

Ninox Profile

Yep, I just tested that. It's too bad the concat() function doesen't have a delimiter argument like the split() function.


A delimiter argument for the concat function would make a lot of sense. In the meantime, I've used the replace() function to replace the default ", " delimiter in the concatenated string with the delimiter of my choice. Of course, you still have to make sure ", " does not appear in any of the actual array elements.

1 2