dinsdag 4 mei 2010

Detecting default values

Use the int prmIsDefault(anytype argument) function.

See: http://sysdictcoder.com/blog/detecting-default-values/

Example:
static void ADU_BMS_prmIsDefault(Args _args)
{
    container   myCon;
                
    str prmIsDefaultTest(container _con = myCon)
    {
        ;
        if (prmIsDefault(_con))
        {
            return "parameter was not provided, using default";
        }
        else
        {
            return "parameter was provided, using provided parameter";
        }
    }
    ;

    info(strfmt("test without parameter: %1", prmIsDefaultTest()));
    info(strfmt("test with parameter: %1", prmIsDefaultTest(myCon)));

    // Infolog output:
    // test without parameter: parameter was not provided, using default
    // test with parameter: parameter was provided, using provided parameter
}

Geen opmerkingen:

Een reactie posten