F_SplitPathName

This function splits a complete path name into its four components. These are stored in the strings named sDrive, sDir, sFileName and sExt.
FUNCTION F_SplitPathName : BOOL
VAR_INPUT
sPathName : T_MaxString;
END_VAR
sPathName: Complete file name as string (type: T_MaxString) in the form: 'X:\DIR\SUBDIR\FILENAME.EXT'.
VAR_IN_OUT
sDrive : STRING(3);
sDir : T_MaxString;
sFileName : T_MaxString;
sExt : T_MaxString;
END_VAR
sDrive: Drive ID (type: T_MaxString) with a colon ('C:', 'A:' etc.).
sDir: Directory name (type: T_MaxString) including the leading and trailing backslash ('\BC \INCLUDE\', '\SOURCE\' etc.).
sFileName: File name (type: T_MaxString).
sExt: Contains the dot and the file extension (type: T_MaxString) (example: '.C', '.EXE' etc.).
Return parameter | Description |
---|---|
TRUE | No error |
FALSE | Error. Check the function parameters. |
Example for a call in ST:
The path name: C:\TwinCAT\Plc\Project01\Data.txt is splitted in the following components:
sDrive: = 'C:'
sDir: '\TwinCAT\Plc\Project01\'
sFileName: 'Data'
sExt: '.txt'
PROGRAM MAIN
VAR
bSplit : BOOL;
sPathName : T_MaxString := 'C:\TwinCAT\Plc\Project01\Data.txt';
sDrive : STRING(3);
sDir : T_MaxString;
sFileName : T_MaxString;
sExt : T_MaxString;
bSuccess : BOOL;
END_VAR
IF bSplit THEN
bSplit := FALSE;
bSuccess := F_SplitPathName( sPathName := sPathName,
sDrive := sDrive,
sDir := sDir,
sFileName := sFileName,
sExt := sExt );
END_IF
Requirements
Development environment |
Target system type |
PLC libraries to include (Category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_System (System) |