@ StripExtension1
Len (sFilename) * SizeOf (tCHAR) =
StringByteLength()
@ StripExtension, StripExtension1 and StripExtension2

Your codes fail when you feed your procedures with "C:\Folder with
.dot\no extension"
In a loop with 800000 loops, my procedure is ca. 29 ms slower than StripExtension1 (which is still the fastest),
but it can handle full paths. remember that Linux ("/") and Windows ("\") are using different path-separators, so my procedure is cross-platform compatible.
Code: Select all
Procedure.s myStripExtension(filename$)
Protected *dot.Character=@filename$+StringByteLength(filename$)-SizeOf(Character)
While *dot\c
If *dot\c = '\' Or *dot\c = '/'
ProcedureReturn filename$
ElseIf *dot\c = '.'
ProcedureReturn PeekS(@filename$, *dot-@filename$)
EndIf
*dot-SizeOf(Character)
Wend
ProcedureReturn filename$
EndProcedure
800 000 loops:
StripExtension1: 439 ms
myStripExtenstion: 468 ms