Posts: 188
Threads: 22
Joined: Mar 2023
Reputation:
12
12-22-2023, 09:36 PM
(This post was last modified: 12-22-2023, 09:37 PM by NakedApe.)
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$
Posts: 1,586
Threads: 59
Joined: Jul 2022
Reputation:
52
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.
Posts: 3,966
Threads: 176
Joined: Apr 2022
Reputation:
219
12-23-2023, 12:21 AM
(This post was last modified: 12-23-2023, 12:23 AM by bplus.)
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.
b = b + ...
Posts: 188
Threads: 22
Joined: Mar 2023
Reputation:
12
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.
Posts: 3,966
Threads: 176
Joined: Apr 2022
Reputation:
219
@NakedApe I am curious, did the code revision I made also work in Mac?
b = b + ...
Posts: 188
Threads: 22
Joined: Mar 2023
Reputation:
12
(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 *.*
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
(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#C...imitations
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..
Posts: 188
Threads: 22
Joined: Mar 2023
Reputation:
12
Also, doh, I see my typo.
result$ = _OPENFILEDIALOG$("Pick a File", "", "", "")
-------
is the same as
-------
result$ = _OPENFILEDIALOG$("Pick a File")
thnx again
Posts: 188
Threads: 22
Joined: Mar 2023
Reputation:
12
Thanks, Steve! That makes sense. And, yeh, I name all my files *.* - is that bad?
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
12-23-2023, 01:05 AM
(This post was last modified: 12-23-2023, 01:06 AM by SMcNeill.)
(12-23-2023, 01:02 AM)NakedApe Wrote: Thanks, Steve! That makes sense. And, yeh, I name all my files *.* - is that bad?
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...)
|