ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Creation of own built-in function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creation of own built-in function

    Hi All,
    How to Create your own built in function like %Date, %Subst or %Char?
    First off all is it possible, if yes then how to create?

    Thanks - NIL
    Cheers...
    Nil

  • #2
    Re: Creation of own built-in function

    As such you could consider procedures as user-defined BIFs but as far as I know you cannot prefix them with a %.

    Comment


    • #3
      Re: Creation of own built-in function

      As noted by vikramx, you can't create your own "built-in functions". If you create something, it won't be "built-in". Instead, you can create service programs and export procedures from them. Referencing those procedures as functions can be a very good extension to the set of "built-in functions".
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #4
        Re: Creation of own built-in function

        Originally posted by vikramx View Post
        As such you could consider procedures as user-defined BIFs but as far as I know you cannot prefix them with a %.
        You mean using SQL create function / create procedure this way we can create our own function or procedure.
        Cheers...
        Nil

        Comment


        • #5
          Re: Creation of own built-in function

          No, not a stored procedure. In RPG a function is called a procedure. He means something like the following.

          Code:
          ctl-opt nomain;
          
          dcl-proc getName;
            dcl-pi *n char(50);
            end-pi;
            dcl-s name char(50);
          
            // do some code to get the name
          
            return name;
          end-proc;
          Now if you compile that up into a service program you can use it in all your other programs. I have pasted below a good example. It uses the fixed format style of RPG.

          Create a Service Program and how to use binding directory. In the following example I am going to create RPGLE functions but in reality you ...

          Comment

          Working...
          X