# LGF_FileDelete (FB / 1.0.0)

Overview

Author: Simatic Systems Support

## Short description

This function block deletes a file that is stored on the memory card of the PLC (SMC) in the `UserFiles` folder.

### Block Interface

| LGF_FileDelete (FB) |
--- | --- | ---
Bool |  |  | execute |  | done |  |  | Bool
String |  |  | fileName |  | busy |  |  | Bool
|  |  |  |  | error |  |  | Bool
|  |  |  |  | fileDoesNotExist |  |  | Bool
|  |  |  |  | status |  |  | Word
|  |  |  |  | diagnostics |  |  | LGF_typeDiagnostics

### Input parameter

Identifier | Data type | Default value | Description
--- | --- | --- | ---
execute | Bool | FALSE | Rising edge starts file delete
fileName | String | '' | Name of file including path: `UserFiles/test.dat`

### Output parameter

Identifier | Data type | Description
--- | --- | ---
done | Bool | TRUE: Commanded functionality has been completed successfully
busy | Bool | TRUE: FB is not finished; new output values can be expected
error | Bool | TRUE: An error occurred during the execution of the functionality
fileDoesNotExist | Bool | True: The file or the path present at `fileName` does not exist
status | Word | 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification
diagnostics | LGF_typeDiagnostics | Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_EXECUTION_FINISHED Execution finished without errors
16#7000 | STATUS_NO_CALL No job being currently processed
16#7001 | STATUS_FIRST_CALL First call after incoming new job (rising edge 'execute')
16#7002 | STATUS_SUBSEQUENT_CALL Subsequent call during active processing without further details
16#8401 | ERR_FILE_PATH Error: File path error: File path must start with 'UserFiles/'.
16#8600 | ERR_UNDEFINED_STATE Error due to an undefined state in state machine
16#8604 | ERR_FILE_DELETE_INIT Error: Read file from SMC - see `diagnostics.subFunctionStatus`
16#8605 | ERR_FILE_DELETE Error: Read file from SMC - see `diagnostics.subFunctionStatus`

## User defined datatype(s)

### LGF_typeDiagnostics (UDT / V1.0.1)

Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

Identifier | Data type | Default value | Description
--- | --- | --- | ---
status | Word | 16#0000 | Status of the Block or error identification when error occurred
subfunctionStatus | Word | 16#0000 | Status or return value of called FB's, FC's and system blocks
stateNumber | DInt | 0 | State in the state machine of the block where the error occurred

## Functional description

With the function `LGF_FileDelete` a file can be deleted from the SIMATIC Memory Card (SMC). The file name must always be specified in full together with the folder name and the file extension in the following format: `UserFiles/test.dat`.

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Simatic Systems Support
| 29.04.2025 | First released version