Are User Defined Functions supported in UniData

297 views Asked by At

Currently investigating migrating from mvBase to Unidata and would like to know if User Defined Functions are supported as I cannot see this in the documentation I have downloaded?

e.g I have DATABASIC program with something like

A = @FUNCTION_NAME(VAR1)

1

There are 1 answers

0
JeffK On

Yes, Unidata supports user defined functions.

To create a function in Unidata, use a line like this on line 1 of the code file:

FUNCTION MY.FUNCTION.NAME( ARG1, ARG2 )

Inside the function, use the RETURN statement to return a result:

RETURN ARG1 + ARG2

To call it, you have to indicate that you're going to use it with the DEFFUN statement in the program that will use the function:

DEFFUN MY.FUNCTION.NAME( ARG1, ARG2 )

I usually put my DEFFUN statements near the top of the program, right after any $INCLUDEs. (The parameter names don't have to match between the FUNCTION and DEFFUN lines, but I don't know of any reason to purposefully make them different.)

After that setup, you can call the function by using its name in an expression:

TOTAL = MY.FUNCTION.NAME( 10, 15 )

After that statement, TOTAL will have a value of 25.

I've never seen a function called with the @FUNCTION_NAME syntax in Unidata.