SplitPath(A_WorkingDir "\" A_ScriptName) ; übergabe eines zu zerlegenden pfades an function.
MsgBox % SplitPath.FileName "`n" SplitPath.NameNoExt "`n" SplitPath.Dir ; ausgabe der array variablen
SplitPath(InputVar) { ; aufgerufene function.
Global SplitPath := {"FileName":"" ; anlage des associative array als Global
, "Dir":"" ; womit die abfrage der werte auch außerhalb der
, "Extension":"" ; function ermöglicht wird
, "NameNoExt":""
, "Drive":""}
SplitPath, InputVar , OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive ; zerlegung des pfades mittels AHK standard befehls
SplitPath.FileName := OutFileName ; transfer der variableninhalte in das array
SplitPath.Dir := OutDir
SplitPath.Extension := OutExtension
SplitPath.NameNoExt := OutNameNoExt
SplitPath.Drive := OutDrive
Return
}
... Zugang nur für Gelangweilte. Die IMHO bessere Lösung bereits im folgenden Beitrag/Senf von@just me. Kudos!
Um just me's Beitrag die entsprechende Würdigung zuteil werden zu lassen, erlaubte ich mir den Titel des Threads entsprechend anzupassen. Merci.
; By just me
; See https://www.autohotkey.com/boards/viewtopic.php?f=10&t=76920
; per inspiration from Bobo
#NoEnv
SPO := SplitPathObj(A_WorkingDir "\" A_ScriptName)
MsgBox % "Dir: " . SPO.Dir . "`nFileName: " . SPO.FileName "`nExtension: " . SPO.Extension . "`nName (no extension): " . SPO.NameNoExt . "`nDrive: " . SPO.Drive ; Array value output.
ExitApp
; ======================================================================================================================
; Function SplitPathObj()
; Replacement for the AHK standard SplitPath command
; The function creates an array with the keys:
; "FileName"
; "Dir"
; "Extension"
; "NameNoExt"
; "Drive"
; and values corresponding to the output variables of the SplitPath command.
; ======================================================================================================================
SplitPathObj(Path2Split) {
Local
; Unbundle the path using the standard AHK command.
SplitPath, Path2Split, Nam, Dir, Ext, NNE, Drv
; Create and return an associative array.
Return {FileName: Nam, Dir: Dir, Extension: Ext, NameNoExt: NNE, Drive: Drv}
}
; ======================================================================================================================