Code archives/Miscellaneous/strip_filename$(filename$)

This code has been declared by its author to be Public Domain code.

Download source code

strip_filename$(filename$) by Kev2003
pass the complete path+filename to the function, the returned string contains just the filename.
filename$="e:test\test\test\filename.bb"


Print strip_filename$(filename$)
MouseWait
End

Function strip_filename$(full_pathname$)

	; loop and sprip the filename from path.  
	For loop=1 To Len(full_pathname$) 
		old_sash_position=sash_position
		sash_position=Instr(full_pathname$,"\",loop)
					
		If sash_position=0 Then
			sash_position=sash_position
		Else
			strip_filename$=Right(full_pathname$,Len(full_pathname$)-old_sash_position)	
		EndIf					
	Next

	Return strip_filename$

End Function

Comments

None.

Code Archives Forum