QB64 Phoenix Edition
OPENFILEDIALOG$ question on a Mac - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: OPENFILEDIALOG$ question on a Mac (/showthread.php?tid=2272)

Pages: 1 2


OPENFILEDIALOG$ question on a Mac - NakedApe - 12-22-2023

I tried using this command for the first time, got the example off of HELP, but it doesn't work for me. Why do I not get a result here? The first line opens up a dialog box, allows me to pick a file, then nada. Thanks in advance for help with my softball question. Ted

result$ = _OPENFILEDIALOG$("Pick a File", "", "", "")
IF results$ <> "" THEN _MESSAGEBOX "File" + results$


RE: OPENFILEDIALOG$ question on a Mac - mnrvovrfc - 12-22-2023

You're supposed to give the second and third parameters. They are not optional. The Wiki page "synposis" is badly written for this function in particular.

The second parameter: The function needs to know where to begin to show files to the user. I don't know a lot about MacOS so I don't know what is the default path for your account's Documents directory. That should be the value to use if you don't care otherwise what it is.

The third parameter is the type of file the user desires to show in the open file requester. In the least this should be "*.*" but again I don't know if that could work on Macintosh computer with its original operating system. If you require text files then it should be "*.txt". If you aren't going to be the only one using the program that you write, it would be nice to indicate a bit of help such as "Text files". This has to be indicated in the fourth parameter.

In the third parameter must use the vertical bar to separate the wildcard paths if there is more than one path desired to be shown in the open file requester. The fourth parameter then must have the same order of descriptions.


RE: OPENFILEDIALOG$ question on a Mac - bplus - 12-23-2023

According to help, OpenFileDialog does not require ANY argument!

Put a pillow in your palm before you slap yourself...

You had a typo and if you don't want to provide arguments do this:
Code: (Select All)
result$ = _OpenFileDialog$("Pick a File")
If result$ <> "" Then _MessageBox "File" + result$

Assuming this works in Mac as in Windows.


RE: OPENFILEDIALOG$ question on a Mac - NakedApe - 12-23-2023

Thanks, mnrvovrfc. Well in the Mac world this works fine:

file$ = _OPENFILEDIALOG$("Open Files", "", "*.txt|*.bas|*.mp3|*.ogg|*.wav", "Files", 0)
IF file$ <> "" THEN _MESSAGEBOX "Information", "You selected " + file$

I tried it a bunch of different ways. The second parameter can be just "" here (which = current directory/folder), but without specific files listed in the third parameter there are no results. Also unfortunately "*.*" doesn't work on a Mac, but "*.xxx" does - weird. Thanks again.


RE: OPENFILEDIALOG$ question on a Mac - bplus - 12-23-2023

@NakedApe I am curious, did the code revision I made also work in Mac?


RE: OPENFILEDIALOG$ question on a Mac - NakedApe - 12-23-2023

(12-23-2023, 12:21 AM)bplus Wrote: According to help, OpenFileDialog does not require ANY argument!

Put a pillow in your palm before you slap yourself...

You had a typo and if you don't want to provide arguments do this:
Code: (Select All)
result$ = _OpenFileDialog$("Pick a File")
If result$ <> "" Then _MessageBox "File" + result$

Assuming this works in Mac as in Windows.

Now we're talkin'. Thanks, bplus! That works great with all files able to be picked - just like *.*  Smile


RE: OPENFILEDIALOG$ question on a Mac - SMcNeill - 12-23-2023

(12-23-2023, 12:21 AM)NakedApe Wrote: Thanks, mnrvovrfc. Well in the Mac world this works fine:

file$ = _OPENFILEDIALOG$("Open Files", "", "*.txt|*.bas|*.mp3|*.ogg|*.wav", "Files", 0)
IF file$ <> "" THEN _MESSAGEBOX "Information", "You selected " + file$

I tried it a bunch of different ways. The second parameter can be just "" here (which = current directory/folder), but without specific files listed in the third parameter there are no results. Also unfortunately "*.*" doesn't work on a Mac, but "*.xxx" does - weird. Thanks again.

You guys should take a moment to look at this:  https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations

Of particular note, in this case, is the list of reserved characters which can't be used in file names:   :

Now, in case that isn't clear above, the ONLY reserved character is the colon.  You can't name a file "foo:2", but you CAN name your file "foo.*", if you want to!

So when you search for "*.*" on a Mac, what you're searching for is the singular file called star-dot-star!  That's a filename and NOT a directive to look for wildcard-dot-wildcard.  Now, some file explorer/openers run under the assumption that nobody is ever going to be silly enough to name a file "*.*" and will use them for wildcards, but apparently the library we use for the open dialogs doesn't make that assumption.  (And, honestly, it shouldn't, as star-dot-star IS a perfectly valid name for a Mac file.)

I'm also curious if you can just completely omit that parameter, and have it work for you.  But, as the file system is designed, it doesn't surprise me that star-dot-star isn't working as you'd expect.  It IS working; it's just working by showcasing that no files with that name are in the directory specified..  Wink


RE: OPENFILEDIALOG$ question on a Mac - NakedApe - 12-23-2023

Also, doh, I see my typo.

result$ = _OPENFILEDIALOG$("Pick a File", "", "", "")
-------
is the same as 
-------
result$ = _OPENFILEDIALOG$("Pick a File")

thnx again


RE: OPENFILEDIALOG$ question on a Mac - NakedApe - 12-23-2023

Thanks, Steve! That makes sense. And, yeh, I name all my files *.* - is that bad?  Wink


RE: OPENFILEDIALOG$ question on a Mac - SMcNeill - 12-23-2023

(12-23-2023, 01:02 AM)NakedApe Wrote: Thanks, Steve! That makes sense. And, yeh, I name all my files *.* - is that bad?  Wink

I'd say so!  How the heck do you tell your porn from your bible studies, under such a naming system?   Good Lord, Pastor Nakey!  How interesting are your Sunday School sermons?!!

(Warning:  Steve *MAY* be typing under the influence of too much eggnog once again...)   Big Grin