Question about converting a string
Blitz3D Forums/Blitz3D Beginners Area/Question about converting a string
| ||
Hi! Simple question, but I don't know how to do it. I'd like to convert a filename with full path to only the filename. E.g: c:\myFolder\myFiles\blah.txt to: blah.txt How can I do this? THANKS |
| ||
Function ClipFilepath$( filepath$ ) For I = Len(filepath$) To 1 Step -1 tmp$ = Mid$(filepath$,I,1) If (tmp$ = "/") Or (tmp$ = "\") Return Mid$(filepath$, I+1) Next Return filepath$ End Function |
| ||
Off the top of my head, not tested,file$="c:\folder\myfiles\blah.txt" name$="" x=Len(file$) Repeat if mid$(file$,x,1)="\" then name$=mid$(file$,x+1) end if x=x-1 until name$<>"" or x=0 check my syntax. SJT |
| ||
Can you just jump out of a for next loop? SJT |
| ||
Can you just jump out of a for next loop? Yeah, it's called 'Exit'.Or you could just use a while loop instead. |
| ||
Hey thanks guys! Works great! |