QB64 Phoenix Edition
setSlash$ - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Prolific Programmers (https://qb64phoenix.com/forum/forumdisplay.php?fid=26)
+---- Forum: SMcNeill (https://qb64phoenix.com/forum/forumdisplay.php?fid=29)
+---- Thread: setSlash$ (/showthread.php?tid=1390)



setSlash$ - SMcNeill - 01-10-2023

One function to set the direction of your slashes for the proper OS.  It's just that simple.  Wink

Code: (Select All)
foo$ = "./mydir/foo.txt"
Print foo$
Print setSlash$(foo$)
foo2$ = ".\mydir\foo.txt"
Print foo2$
Print setSlash$(foo2$)
foo3$ = "./mydir\foo.txt"
Print foo3$
Print setSlash$(foo3$)

Function setSlash$ (text$)
    temp$ = text$
    $If WIN Then
        desiredSlash$ = "\"
        badSlash$ = "/"
    $Else
            desiredSlash$ ="/"
            badSlash$ = "\"
    $End If
    Do
        p = InStr(temp$, badSlash$)
        If p Then Mid$(temp$, p, 1) = desiredSlash$
    Loop Until p <= 0
    setSlash$ = temp$
End Function