Page 1 of 2

Double Quotes Bug

Posted: Sun Apr 30, 2023 9:09 am
by Piero
This is really annoying!
I already emailed support, posting here so you can avoid unexpected problems!

Code: Select all

FilePath$ = #DQUOTE$+ OpenFileRequester("","","",0) +#DQUOTE$
;  Enclosed in #DQUOTE$ for paths with spaces etc…

RunProgram("open",FilePath$,"") ; Will open as if double-clicked
;  Paths with double quotes will not open!
No way to escape double quotes on RunProgram parameter!!!

Other problems (Mac M1 Monterey):
No Sound!!!
Toolbar: no text, keeps customization only if made on prefs…
 
// Moved from "Bugs - Mac OSX" to "Coding Questions" (Kiffi)

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 10:27 am
by BarryG
Why have you got "open" there? That's not the file from OpenFileRequester().

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 10:53 am
by Piero
BarryG wrote: Sun Apr 30, 2023 10:27 am Why have you got "open" there? That's not the file from OpenFileRequester().
I used "open" so you can test the RunProgram parameter bug.
open is a "Terminal Command" to open files (like a Finder double-click) used here with the file from OpenFileRequester() as parameter.

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:21 am
by BarryG
Okay, that answers that. But you don't have to come in here as a newbie and start yelling at us in big text.

Now, does this topic help your question? -> viewtopic.php?t=68147

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:29 am
by Piero
BarryG wrote: Sun Apr 30, 2023 11:21 am Okay, that answers that. But you don't have to come in here as a newbie and start yelling at us in big text.
Now, does this topic help your question? -> viewtopic.php?t=68147
Forgive me for the "yelling".
No, that doesn't help; the problem is not the program, it's the parameter string.

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:35 am
by mk-soft
Solution

Code: Select all

FilePath$ = OpenFileRequester("","","",0)
If FilePath$
  RunProgram("open",#DQUOTE$ + FilePath$ + #DQUOTE$,"")
EndIf

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:44 am
by Piero
mk-soft wrote: Sun Apr 30, 2023 11:35 am Please move to 'Code Question'
Why please? I consider this a bug... try open a file named 'this "is" text.txt' with the code above and you will see…
Same applies if the containing folder has double quotes on name...

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:45 am
by mk-soft
Welcome Piero
The bug forum pages are about bugs found in the IDE or compiler. But only after confirmation from experienced users.

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:51 am
by mk-soft
File names must not have a dquote because these are separators when parameters are passed.
Rule on the OS and is not due to PB

Try it in the terminal. it doesn't work there either.

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 11:56 am
by Piero
mk-soft wrote: Sun Apr 30, 2023 11:45 am Welcome Piero
The bug forum pages are about bugs found in the IDE or compiler. But only after confirmation from experienced users.
Hi! I'm "experienced" in this kind of stuff (but I can make mistakes…)
PLEASE test and tell me, but believe me: do not waste too much time trying to escape the string… I tried all I could…

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 12:07 pm
by Piero
mk-soft wrote: Sun Apr 30, 2023 11:51 am Try it in the terminal. it doesn't work there either.
It works in Terminal if you enclose in single quotes:
open '/Users/username/Desktop/New Folder/"Hello World".txt'

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 12:20 pm
by mk-soft
Interesting problem ;)

But not with complex filename as 'this "is" text.txt'
But i found a solution as url path

Code: Select all

FilePath$ = OpenFileRequester("","","",0)
If FilePath$
  Debug FilePath$
  fileUrl$ = "file://" + URLEncoder(FilePath$)
  Debug fileUrl$
  RunProgram("open","-u " + fileUrl$,"")
EndIf

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 12:33 pm
by Piero
mk-soft wrote: Sun Apr 30, 2023 12:20 pm Interesting problem ;)

But not with complex filename as 'this "is" text.txt'
But i found a solution as url path

Code: Select all

FilePath$ = OpenFileRequester("","","",0)
If FilePath$
  Debug FilePath$
  fileUrl$ = "file://" + URLEncoder(FilePath$)
  Debug fileUrl$
  RunProgram("open","-u " + fileUrl$,"")
EndIf
Many thanks for the solution!!!
But I still consider it a bug, because it affects the parameter string, e.g. if you want to run program osascript with parameter "tell app "Finder" to activate"... or any other "Console" command that needs double quotes on parameters...

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 12:46 pm
by mk-soft
I don't see it as a bug, as a problem.

Double quotes is always the indication that the following parameter contains blanks and interpreted within double quotes as a single parameter.

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 1:10 pm
by Piero
mk-soft wrote: Sun Apr 30, 2023 12:46 pm I don't see it as a bug, as a problem.
Double quotes is always the indication that the following parameter contains blanks and interpreted within double quotes as a single parameter.
Then let's see it as a BIG problem that just needs at least one way to "escape" double quotes for some "console commands"...

…like this "Terminal Magic":
open "/Users/user/Desktop/New Folder/'this \"is\" text'.txt"

 :wink:

...and THANKS AGAIN!