# CODESYS DELETE

Instructions · `DELETE` · verification: source checked

DELETE is a standard string function in the CODESYS Standard library. It removes a given number of characters from a string, starting at a specified position, and returns the remaining string as a STRING(255) value. It is written as DELETE(STR, LEN, POS) and is used in structured text programs.

## Specification

| Property | Value |
|---|---|
| Language | structured text |
| Code | DELETE |
| Group | String Functions |
| Syntax | DELETE (STR, LEN, POS) |
| Dialect | CODESYS |

### Parameters

| Name | Data type | Description |
|---|---|---|
| STR | STRING(255) | String to be modified. |
| LEN | INT | Length of the partial string to be deleted, number of characters. |
| POS | INT | Position in STR after which the deletion starts, counted from left starting with 1. |

## Study notes

- Declared as FUNCTION DELETE : STRING(255).
- Return value is the string remaining after deletion.
- Position POS is counted from the left, starting with 1; both POS = 0 and POS = 1 address the first character.
- Example: VarSTRING1 := DELETE('SUXYSI',2,3); gives the result 'SUSI'.
- The current implementation is not correct for POS = 0: LEN is internally reduced by one. This cannot be changed for compatibility reasons.
- The library recommends using values in the range specified by IEC 61131-3, where the smallest value for POS is 1.
- The documentation lists an InOut scope section with no parameters.

## Sources

1. [Beckhoff Information System](https://infosys.beckhoff.com/content/1033/tcplclib_tc2_standard/74412555.html) (accessed 2026-10-26)
2. [CODESYS Group](https://content.helpme-codesys.com/en/libs/Standard/Current/String-Functions/DELETE.html) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/iec-delete  
JSON: https://machineschema.com/instruction/iec-delete.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
