This simple function will return the name part of the given file or folder name. That is the part left of the rightmost found dot (if any). The dot itself is not included in the result, as it belongs to the name extension, which you can get using the function FileExtension$() instead.
SYNTAX:
name$ = FileNamePart$ (file$)
INPUTS:
file$ (STRING)
- The file or folder name to get the name part from. Empty input is allowed here and will result into an empty name part.
- May also have a path, then only the file part (FilePart$()) is checked and the result will contain the same path, as far as a valid name part was found.
RESULT:
name$ (STRING)
- Depending on the given file or folder name:
- The found name part (regular operation).
- May be identical to file$, if it was a name without extension (no dot found).
- Will also contain the original path (if given).
- Empty, if input was empty or a extension only (leading dot found).
- Is also empty, if a path was given, but without an actual name (file part empty)
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.