SplitPath: The corner stone of every good file oriented prog
Oct 19, 2023 22:35:20 GMT 1
scalion and Roger Cabo like this
Post by (X) on Oct 19, 2023 22:35:20 GMT 1
SplitPath is a new command to me and I love it!
I was wondering:"What is the name of that new GFA command that will parse the full path 'automatically'?
Was it ParsePath?, GetPathInfo?, FileSystemObject? GetDir? GetPath? GetName? GetExt?
I stumbled upon the SplitPath command included in the GfaWinX.lg32 library! That's it: "SplitPath"!
Was it ParsePath?, GetPathInfo?, FileSystemObject? GetDir? GetPath? GetName? GetExt?
I stumbled upon the SplitPath command included in the GfaWinX.lg32 library! That's it: "SplitPath"!
Here is the Help Document reference...
SplitPath command
Requires: GfaWinx.lg32
Purpose
Breaks a path name (UNC included) into its components drive, directory, filename, and extension.
Syntax
SplitPath FName$, Drive$, Dir$, FileName$, Ext$
FName$ : string expression
Drive$, Dir$, FileName$, Ext$ : string variables
Description
SplitPath parses the filepath from the string expression FName and stores it's components drive, directory, filename, and extension in the specified string variables. SplitPath handles both normal path and UNC path expressions.
After parsing Drive$ contains the drive-letter plus : ("X:"), Dir$ contains the path starting and ending with a backslash ("\path\sub\"), FileName$ contains the filename without extension, and Ext$ holds the extension starting with the dot (".ext").
When FName is an UNC path specification Drive$ which contains the first part starting with \\ until (but without) the next backslash ("\\MyServer"), the other values are the same.
Example
Remarks
SplitPath is compatible with the C library function _splitpath().
See Also
Dir, FileName(ShowOpen)
{Created by Sjouke Hamstra; Last updated: 24/08/2021 by James Gaite}
Requires: GfaWinx.lg32
Purpose
Breaks a path name (UNC included) into its components drive, directory, filename, and extension.
Syntax
SplitPath FName$, Drive$, Dir$, FileName$, Ext$
FName$ : string expression
Drive$, Dir$, FileName$, Ext$ : string variables
Description
SplitPath parses the filepath from the string expression FName and stores it's components drive, directory, filename, and extension in the specified string variables. SplitPath handles both normal path and UNC path expressions.
After parsing Drive$ contains the drive-letter plus : ("X:"), Dir$ contains the path starting and ending with a backslash ("\path\sub\"), FileName$ contains the filename without extension, and Ext$ holds the extension starting with the dot (".ext").
When FName is an UNC path specification Drive$ which contains the first part starting with \\ until (but without) the next backslash ("\\MyServer"), the other values are the same.
Example
$Library "gfawinx"
Debug.Show
Local String sDrive, sDir, sFileName, sExt
SplitPath "C:\WINDOWS\SYSTEM.INI", sDrive, sDir, sFileName, sExt
Trace sDrive ' "C:"
Trace sDir ' "\WINDOWS\"
Trace sFileName ' "SYSTEM"
Trace sExt ' ".INI"
SplitPath "\\MyServer\Drive-C\MyDir\file.ext", sDrive, sDir, sFileName, sExt
Trace sDrive ' "\\MyServer"
Trace sDir ' "\Drive-C\MyDir\"
Trace sFileName ' "file"
Trace sExt ' ".ext"
Remarks
SplitPath is compatible with the C library function _splitpath().
See Also
Dir, FileName(ShowOpen)
{Created by Sjouke Hamstra; Last updated: 24/08/2021 by James Gaite}