EMS Client Programming in RPG

Use the information in this section as a guide when you extend the prototype file, and when you code EMS Client programs in RPG.

Coding your own applications in RPG requires that you extend the prototype file to include all the TIBCO Enterprise Message Service calls that your application uses.

Parameter passing protocol in C differs from the parameter passing protocol in RPG. By default RPG passes parameters by reference, unless you explicitly code to pass by value. In contrast, C passes parameters by value, though you can explicitly supply a pointer referencing a location.

The following table guides the translation from C to RPG. Each section of the table addresses a specific type of parameter passing in C, followed by the equivalent constructs in RPG.

When C Passes a Non-String by Value
C Prototype foo(int order)
C Program Call int order;

foo(order);

RPG Prototype ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    d foo              pr

    d order                          10i 0 value

RPG Program Call ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    D order            S            10i 0 inz(37)

    C                    callp    foo(order)

When C Passes a Non-String by Reference
C Prototype foo(int* order)
C Program Call int order;

foo(&order);

RPG Prototype ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    d foo              pr

    d order                          10i 0

RPG Program Call ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    D order            S            10i 0 inz(37)

    C                    callp    foo(order)

When C Passes a String by Value
C Prototype foo(char* desc)
C Program Call char* desc;

foo(desc);

RPG Prototype ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    d foo              pr

    d desc                            *    value

RPG Program Call ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    D foo              S            11A

      /free

         desc = 'TIBRVLISTE' + X'00';

         foo(%addr(desc));

      /end-free

When C Passes a String by Reference
C Prototype foo(char** desc)
C Program Call char* desc;

foo(&desc);

RPG Prototype ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    d foo              pr

    d desc                            *    

RPG Program Call ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5

    D foo              S            11A

    D pDesc            S            *     inz(%addr(desc))

      /free

         desc = 'TIBRVLISTE' + X'00';

         foo(%addr(pDesc);

      /end-free