Navigation:  Appendices > Macro Language > Built-in Functions > All Functions (Alphabetical) >


Previous pageReturn to chapter overviewNext page

int = StrToIntDef(sString, nDefaultVal)


The macro function IntToStrDef() converts the string sString into a number, in the same manner as does the function IntToStr but with the added feature that if the value of sString does not represent a valid number, then instead of generating an error, the function will return the value nDefaultVal.


// 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


See also: StrToInt, IntToStr.

Topic 178795 updated on 01-Nov-2016.
Topic URL: