---
url: /flow/guide/scripting-reference/functions/conversion/strtointdef.md
---

# StrToIntDef

## Declaration

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

### Example

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

## Description

StrToIntDef converts a string into an integer data type. If string does not contain a integer value it will default to def.
