custom function with eval

145 views
Skip to first unread message

JOSE L MARTINEZ-AVIAL

unread,
Sep 24, 2015, 4:41:39 AM9/24/15
to jb...@googlegroups.com
Hello,
  I'm trying to develop a custom function so it can be used with EVAL in a jbase command. To begin, I tried to create a function that receives just one argument, as follows:

FUNCTION FTEST(A)
   RETURN (A:"-1")
END

but if use it with LIST, for example:

jsh miaeco01 ~ -->LIST F.SPF 'SYSTEM' EVAL'FTEST(@ID)'
 ** Error [ SUBROUTINE_PARM_ERROR ] **
'SUBROUTINE FTEST' called with incorrect arguments , Line     1 , Source jql_listcolumnar.b
jsh miaeco01 ~ -->

It gives an error about an invalid number of arguments, so just out of curiosity I tried the following:

FUNCTION FTEST(A,B)
   RETURN (A:"-1")
END

And the same command now returns this:
jsh miaeco01 ~ -->LIST F.SPF 'SYSTEM' EVAL'FTEST(@ID)'

LIST F.SPF 'SYSTEM' EVAL'FTEST(@ID)'                                                                                                                                         PAGE    1 02:52:38  24 SEP 2015

@ID...    FTEST(@ID)

SYSTEM    SYSTEM-1 

 1 Records Listed

jsh miaeco01 ~ -->

I don't know what the second argument is for, because if I try to use in the function, the LIST crashes
FUNCTION FTEST(A,B)
   RETURN (A:"-1":B)
END


jsh miaeco01 ~ -->LIST F.SPF 'SYSTEM' EVAL'FTEST(@ID)'
jBASE: Segmentation violation. Aborting

Anybody knows about that second argument is, and if I can send more than one argument to the function?

Thanks!


Jose L Martinez Avial

unread,
Sep 28, 2015, 8:25:08 AM9/28/15
to jb...@googlegroups.com
Hello,
Nobody know if this can be done, and how?

Thanks
JL

Sent from my iPhone

Ed Clark

unread,
Sep 28, 2015, 10:47:15 AM9/28/15
to jb...@googlegroups.com
There’s some documentation at http://jbase.com/r5/knowledgebase/manuals/3.0/30manpages/man/sup12_I_TYPES.htm.
You need to use a subroutine instead of a function. The type processor expects the result to be returned in the first parameter instead of by a RETURN statement, and passes the eval arguments to the subroutine as the 2nd and subsequent parameters.
> --
> --
> IMPORTANT: T24/Globus posts are no longer accepted on this forum.
>
> To post, send email to jB...@googlegroups.com
> To unsubscribe, send email to jBASE-un...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/jBASE?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups "jBASE" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jbase+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages