Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>_parinfo() parameter type checking </b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_parinfo()         Parameter type checking 


Syntax Usage:  #include     "extend.h"

               int          _parinfo(order)

               int          order;  Placement in list of parameters to
                                    type-check

Description:   _parinfo() is used to test the type of a passed
               parameter.  _parinfo(0) returns the number of parameters
               passed.  _parinfo(n) returns the type of parameter where
               n is the position in the parameter list.  The value
               returned is one of the following:

               /* _parinfo types from EXTEND.H */
               #define  UNDEF       0
               #define  CHARACTER   1
               #define  NUMERIC     2
               #define  LOGICAL     4
               #define  DATE        8
               #define  MPTR        32      /* or'ed with type when
                                               passed by reference */
               #define  MEMO        65
               #define  ARRAY       512

               To check that a parameter has been passed by reference,
               add its type value to MPTR(32) and test for that sum.  If
               a character string is passed by reference, _parinfo(n)
               should equate to 33.

----------------------------------- Example --------------------------------

   In Clipper:

    char_var = "STRING"

    C_udf(@char_var)
    C_udf(char_var)


   In C:

    #include "extend.h"

    CLIPPER udf()
    {

        printf("%s %s PASSED BY REFERENCE\r\n", _parc(1),
            ISBYREF(1) ? "IS" : "IS NOT");

        \* this is the same *\

        printf("%s %s PASSED BY REFERENCE\r\n", _parc(1),
            _parinfo(1) == CHARACTER + MPTR ? "IS" : "IS NOT");

        printf("_parinfo(1) = %d\r\n\r\n", _parinfo(1));

    }


------------------------------- Example template ---------------------------

   The following user-defined C function, cfunc(), receives four
   parameters from Clipper: a character type, a numeric, a logical, and
   a date; defines the C variables to receive the values, then validates
   the parameters.

   #include "extend.h"

   CLIPPER cfunc()
   {

    char            *parm1;
    double          parm2;
    int             parm3;      /* logical is declared
                                   as int */
    char            *parm4;     /* date declared as
                                   char (YYYYMMDD) */

    if (PCOUNT == 4         && ISCHAR(1) && ISNUM(2)
                            && ISLOG(3)  && ISDATE(4))

        {
            <code to execute parameters valid>
        }

        else
        {
            <code to execute parameters invalid>
        }

   }

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson