---
url: >-
  /statelake/scripting-reference/functions-and-procedures/conversion-functions/strtointdef.md
---

# StrToIntDef

**StrToIntDef** converts a **String** into an **Integer** data type.

If the **String** does not contain a **Integer** value it will default to the value as supplied as the **def** parameter.

Declaration: Function StrToIntDef( const S : string; def: Longint) : Integer;

The example is.

```pascal
procedure OnMapEvent(var Value:Variant);
var MyAmount : String;
begin
  MyAmount := '123';
 //Value will be equal to 123 or 0 in case of error
  Value := StrToIntDef(MyAmount,0);
end;
```
