This simple function will return the file part of the given file or folder specification. That is just the final name component after the rightmost backslash, which is usually the actual file or folder name without the path. To get the path, you would use the function PathPart$() instead.
SYNTAX:
file$ = FilePart$ (fileSpec$)
INPUTS:
fileSpec$ (STRING)
- The file or folder specification to get the file part from. Empty input is allowed here and will result into an empty file part.
RESULT:
file$ (STRING)
- Depending on the given file or folder specification:
- The final name component, usually the file or folder name (regular operation).
- May be identical to fileSpec$, if it was a single name component only, which usually is a file or folder name in the current working directory (no backslash found).
- Empty, if input was empty or a path only (trailing backslash found).
While the first case (identical or not) is ok, you should explicitly check for the second case (empty) if required, as it may cause errors when trying to OPEN, MKDIR, CHDIR etc. with an empty name.