Restored from previous forum. Originally posted by PB.
Until this command becomes native (hopefully!), you can use this procedure to
get the file extension from a given string. If no extension exists, the return
value is null.
Code: Select all
Procedure.s GetExtPart(file$)
;strip any trailing quotes.
While Right(file$, 1) = Chr(34)
file$ = Left(file$, Len(file$) - 1)
Wend
;now get the extension.
For r = Len(file$) To 1 Step -1
If Mid(file$, r, 1) = "."
ext$ = Mid(file$, r, 999)
r = 1 ;to exit loop.
EndIf
Next
ProcedureReturn ext$
EndProcedure
e$ = GetExtPart("c:\test.txt") ;e$ will be ".txt"
Debug e$
Edited by - PB on 02 May 2002 00:19:40