12-05-2022, 03:12 AM
Personally, I'd go this way:
Here we sort out our slash direction to begin with, and save it in a stored variable for use whenever it's needed in our program. After all, if it's needed to find ExePath, then it's going to be needed when we try and make use of that path and open a file, or anything else with it as well.
Code: (Select All)
$If WIN Then
Dim Shared As String * 1 Slash: Slash = "\"
$Else
Dim Shared As String * 1 Slash: Slash = "/"
$End If
Print ExePath
Function ExePath$
ExePath$ = Left$(Command$(0), _InStrRev(Command$(0), Slash) - 1)
End Function
Here we sort out our slash direction to begin with, and save it in a stored variable for use whenever it's needed in our program. After all, if it's needed to find ExePath, then it's going to be needed when we try and make use of that path and open a file, or anything else with it as well.