Something is wrong with MID:
wchar buffer[260] = "C:\xxxx\xxx.bas"
dim i as long, pch as word at strptr(buffer)
for i = len(buffer) to 1 step -1
if pch[i] = asc(":") or pch[i] = asc("\") or pch[i] = asc("/") then
buffer = mid(buffer, i + 1)
print buffer + " " + i
exit for
end if
next
After buffer = mid(buffer, i + 1), buffer becomes empty.