TrFile_GetExtension |
Returns the extension of a file path
Syntax
TrFile_GetExtension ( switches ; filePath )
Parameters
switches | not used, reserved for future use. Leave blank or put "-Unused" |
filePath | the path to the file of which you want the extension |
Returned Result
Data type returned
Text
Result
the extension, which is the part of a filename in the file path after the last period.
If the file name in the path does not have an extension “” is returned.
Originated in
Troi File Plug-in 12.0
Compatibility
FileMaker Pro 17 to FileMaker Pro 21 (2024)
Considerations
You can use this function to easily determine the extension of a path (or filename).
If the file name in the path does not have an extension “” is returned.
Note that the plug-in checks if the last period is not in a subfolder of the path, so on macOS “MacHD:data.kip:filename” will not return “.kip:filename” as the extension but “” as expected.
And on Windows “C:\\Users\data.kip\filename” will not return “.kip\filename” as the extension but “”.
The function also works with (fully qualified) FileMaker Pro paths which use forward slashes.
The plug-in does not test if the path is correct or if the file exists.
Example
TrFile_GetExtension ( "" ; "C:\Test.txt" ) ]
This will return the extension “txt”.
TrFile_GetExtension ( "" ; "MacHD:data.kip:filename" ) ]
This will return the extension “”.
TrFile_GetExtension ( "" ; "/MacHD/trident/submar/filename.log" ) ]
This will return the extension “log”.
Example 2
Set Variable [ $Extension ; TrFile_GetExtension ( "" ; "filemac:/Mac HD/Users/Smith/report.fmp12" ) ]
This will set the variable $Extension to “fmp12”.
Used in example file
Attribute.fmp12
Related functions
TrFile_Exists |
TrFile_GetFileName |
TrFile_GetTypeOfItem |
Related topics
Troi File Plug-in online help (overview)