---
url: /flow/guide/scripting-reference/functions/string/leftpad.md
---

# LeftPad

## Declaration

`Function LeftPad( S : string; Ch : Char; Len : Integer) : string`

### Example

```pascal
procedure OnMapEvent(var Value:Variant);
begin
  Value := LeftPad('abc','1',5); // returns 'abc11' - two padding characters added, leaving S left-justified
  Value := LeftPad('abc','1',2); // returns 'abc' - no padding necessary (and no truncation)
end;
```

## Description

Returns string S left-justified within the output, and padded with the Ch character (on the right) if necessary to make the output up to length Len.

Note: Example and Description corrected November 2011. Previous version had LeftPad and RightPad interchanged.
