Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
? ForceDrive(GetFile(),"X")
Function ForceDrive(tcFile, tcDriveletter)
Return IIf(Left(tcFile,1)="\",tcFile, tcDriveletter+SubStr(tcFile,2))
You surely mean a latter and ':\'. You can of course also remove that part, too and later add it back by passing in 'X:\' instead of only 'X'. It's merely a change of Substr starting at position 4 instead of 2.Mike said:In short, if the string starts with a letter and a "\", drop the first two characters, otherwise leave them alone.
lcPath = [d:\temp\]
lcDriveStripped = STRTRAN( lcPath , JUSTDRIVE( lcPath ) )
? lcDriveStripped
it checks the whole string, while just the left character already tells you what to do.
lc_saveas= "\\share\folder1\folder2"
? SUBSTR(lc_saveas,RAT(":\",lc_saveas)+1) && \\share\folder1\folder2
? SUBSTR(lc_saveas,RAT(":\",lc_saveas)+2) && \share\folder1\folder2
LOCAL Test AS String
m.Test = ""
DO WHILE m.Test != "*"
m.Test = INPUTBOX("Enter a full path expression", "UNDRIVE()", m.Test, 0, "", "*")
IF m.Test != "*"
MESSAGEBOX("Full path: " + m.Test + CHR(13) + "UnDrived: " + UnDrive(m.Test))
ENDIF
ENDDO
FUNCTION UnDrive (Path AS String) AS String
LOCAL RegExp AS VBScript.RegExp
m.RegExp = CREATEOBJECT("VBScript.RegExp")
m.RegExp.Pattern = "^([A-Za-z]:\\?|\\\\(\?\\UNC\\)?[^\\]+\\[^\\]+\\?|\\)"
m.RegExp.Global = .T.
RETURN m.RegExp.Replace(m.Path, "")
ENDFUNC