requesting a file

BlitzPlus Forums/BlitzPlus Programming/requesting a file

I don't think there is a way for RequestFile to do it (yet?)... You must manipulate the returned path. I can think of two ways to do it off the top of my head: the Blitz way, and the Windows way. Both have advantages and disadvantages.

The "Blitz" way:
a$ = "C:\My Documents\file.txt"
b$ = GetFilenameFromPath(a$)
Notify b$

Function GetFilenameFromPath$(path$)
	Local index% = 0
	Repeat
		index = Instr(path$, "", 0)
		path$ = Right$(path$, Len(path$)-index)
	Until index = 0
	Return path$
End Function


The advantages of this is that it's fully supported in Blitz and is likely to work in any case. The disadvantages is that you have to provide it yourself, it may be a little slower, and it's not technically supported by Windows. It assumes that the file name is always what appears after the last backslash.

Here's the "Windows" way:
[put this in a .decls file]
.lib "shlwapi.dll"
PathFindFileName$(Path$):"PathFindFileNameA"

[put this in your .bb file]
a$ = "C:\My Documents\file.txt"
b$ = PathFindFileName(a$)
Notify b$


The advantage here is that the functionality is already provided by Windows. The disadvantage is that it may not be supported by ALL versions of Windows. Shlwapi.dll (Shell Light-weight utility API) is included with Windows, but I *think* it will only work if you have IE5 installed (in other words, Win98SE and on by default). I'm not positive.

There are probably other solutions.