This does not get a filename on the first pass, on subsequent calls, it does return a filename:
FileFilter is a | delimited string from some globals set up to restrict selection to one of the filetypes I'm interested in opening.
Ex: $TextFiles = "Text Files (*.txt)|*.txt|Source Files (*.src)|*.src"
The first time it's called, I get garbage like:
<00><00>À<00><00><00><13><00><01>m FH6À<00>P6À<00>X<00><00><00>˜6À<00>$ô<12><00>Páï|„ö<12><00>d~û
from the procedure.
P.S. The additional & CHR$(0) tacked onto the various function strings is a late addition in attempting to determine what was wrong, they were not present originally, and the function was still returning garbage on first call.
Code:
FUNCTION GetFileName(FileFilter AS STRING, FilePath AS STRING, _ FileTitle AS STRING, OpenMode AS LONG) AS STRING DIM OFName AS OPENFILENAME, FileName AS STRING, myOpen AS LONG DIM strExt AS STRING, strName AS STRING, strPath AS STRING, strFilter AS STRING strExt = PARSE$(FileFilter, "|", 2) strExt = PARSE$(strExt, ".", 2) strExt = PARSE$(strExt, ";", 1) & CHR$(0) strName = CHR$(0) strPAth = CHR$(0) IF FilePath <> "" THEN strPath = FilePath & CHR$(0) IF RIGHT$(FilePath, 1) <> "\" THEN strName = PARSE$(FilePath, "\", PARSECOUNT(FilePath)) REPLACE strName WITH "" IN strPath strName = PARSE$(strName, ".", 1) & CHR$(0) END IF END IF strFilter = FileFilter & "||" REPLACE "|" WITH CHR$(0) IN strFilter myOpen = OpenMode OR %OFN_ENABLESIZING FileName = STRING$(%max_path, " ") DISPLAY OPENFILE hwndWinMain,,, FileTitle, strPath, strFilter, strName, _ strExt, myOpen TO FileName #DEBUG PRINT FileName GetFileName = FileName END FUNCTION
Ex: $TextFiles = "Text Files (*.txt)|*.txt|Source Files (*.src)|*.src"
The first time it's called, I get garbage like:
<00><00>À<00><00><00><13><00><01>m FH6À<00>P6À<00>X<00><00><00>˜6À<00>$ô<12><00>Páï|„ö<12><00>d~û
from the procedure.
P.S. The additional & CHR$(0) tacked onto the various function strings is a late addition in attempting to determine what was wrong, they were not present originally, and the function was still returning garbage on first call.
Comment