KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Default values for missing parameters
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: October 24, 2023

Methods and functions can be called with optional parameters. This means that within a method or function, any amount of parameters can be declared, and some parameters can be omitted when the method or function is called. Below shows a mapping of what the default value for a missing parameter would be depending on its declared type:

Declared Type | Default Value
----------------------------------
Variant ............. Undefined
Time ................ 00:00:00
Text ................. ""
Real .................. 0
Pointer .............. Nil
Picture .............. 0 octets
Object ............... null
Integer .............. 0
Date .................. 00/00/00
Collection ........... null
Boolean ............. False
Blob .................. 0 octets

This information can be useful for building methods with optional parameters or error checking.

Example:

Class constructor($param : Collection)
  If ($param=Null)
    return
  End if

  For each ($item; $param)
    // Do something...
  End for each