5.5.2   HGetPPar

HGetPPar (see figure 5.25) returns the reference to a MIXED_PAR array of Hcpar structures, which contain the parameter values of the input control parameter at the position par (1… n). Contrary to HGetCPar (see section “HGetCPar”), HGetPPar is much more efficient in terms of memory overhead, because it just returns pointers to the values instead of copying them. On the other hand, the parameter values may only be read and must not be modified. Note that for every parameter value, its type (LONG_PAR, DOUBLE_PAR, STRING_PAR) is also stored within the Hcpar structure. Therefore, the same control parameter may contain values of different control data types. In case the input array is of different type to MIXED_PAR, the array is copied and converted to an ad hoc allocated memory buffer of Hcpar structures. This buffer is freed automatically when the operator returns. The current number of parameter values is returned in num.

Note that HGetPPar automatically checks the result state of the underlying procedure similarly to the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HGetPPar yourself.

Figure 5.26 shows the usage of HGetPPar together with HGetPElemL and HGetPElemS (compare section “HGetPElemL, HGetPElemD, HGetPElemS”).

    INT4_8 const     *ctrl1;  /* LONG_PAR array                       */
    char const*const *ctrl2;  /* STRING_PAR array                     */
    Hcpar            *ctrl3;  /* MIXED_PAR array of Hcpar structures  */
    INT4_8           num;     /* length of an input array             */

    /* Read all values of parameter number 1. Say, we expect a   */
    /* LONG_PAR array but also tolerate double values.           */
    HGetPElemL(proc_handle,1,CONV_CAST,&ctrl1,&num);
    /* now ctrl1[0] == 5; ctrl1[1] == 6;                         */
    /* Read a string in parameter number 2. Say, we expect a     */
    /* STRING_PAR array.                                         */
    HGetPElemS(proc_handle,2,CONV_NONE,&ctrl2,&num);
    /* now ctrl2[0] == "Text"                                    */
    /* Read a tuple of float values in parameter number 3.       */
    /* At this parameter we handle any value type                */
    HGetPPar(proc_handle,3,&ctrl_val3,&num);
    /* now ctrl3[0].type == DOUBLE_PAR, ctrl3[0].par.d == 1.7    */
    /*     ctrl3[1].type == LONG_PAR,   ctrl3[1].par.l == 4      */
    /*     ctrl3[2].type == STRING_PAR, ctrl3[2].par.s == "ctrl" */
      ...

Figure 5.26: Read the control parameter values of the operator call demo([5,6.8],'Text',[1.7,4,'ctrl']) using HGetPElemL, HGetPElemS, and HGetPPar.