StrToIntDef

Convertit en nombre une chaîne qui représente un entier (décimal ou hexadécimal), avec renvoi de def en cas d'erreur.

Syntaxe

function StrToIntDef(str: String; def: Integer): Integer
str: chaîne a convertir en entier
def: valeur par défaut à utiliser

Remarques

Convertit en nombre une chaîne qui représente un entier (décimal ou hexadécimal). Si la chaîne débute par un '$', elle sera comprise comme étant une valeur hexadécimale.

Si str ne représente pas un nombre valide, StrToIntDef retourne def.

Pour déclencher une exception en cas de nombre non valide, voir StrToInt.

Exemples

StrToIntDef('123', 456) // renvoi 123
StrToIntDef('zzz', 456) // renvoi 456

var s := '12';

s.ToIntegerDef(3); // 12

s := 'abc';

s.ToIntegerDef(3); // 3

Classification

Internal