xHarbour Reference Documentation > Command Reference |
Assigns a default value to a NIL argument.
DEFAULT <varName1> TO <xValue1> ; [, <varNameN> TO <xValueN> ]
The DEFAULT TO command assigns the value of <xValue> to the variable <varName> when <varName> contains NIL. Multiple variables can be assigned default values by separating a list of TO options with commas.
The command is used in functions and procedures that accept optional arguments. Optional arguments receive NIL as value and are assigned default values using DEFAULT TO.
See also: | :=, Default(), PValue(), IF, STORE, Valtype() |
Category: | Memory commands |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example shows a function that normalizes strings in // length and capitilization. FUNCTION Normalize( cStr, nPad ) DEFAULT cString TO "" , ; nPad TO Len(cStr) RETURN PadR( Upper( cStr[1] ) + Lower( SubStr( cStr, 2 ), nPad )
http://www.xHarbour.com