int = StrToIntDef(sString, nDefaultVal)
This macro function converts the string sString into a number, in the same manner as does the function StrToInt.
If sString does not represent a valid integer, or its value is outside the supported integer range, this function returns nDefaultVal instead of generating a conversion error. The default is itself an integer and can use the same supported range.
// same behaviour as StrToInt()
StrToIntDef('1024', -1) // 1024
StrToIntDef('0012', -1) // 12
// the following would generate an error if used with StrToInt()
StrToIntDef('1.024', -1) // -1
StrToIntDef('1,024', 12) // 12
StrToIntDef('Elvis', 666) // 666
Topic 178795, last updated on 09-Oct-2026