Double Quotes Bug

Just starting out? Need help? Post your questions and find answers here.
User avatar
mk-soft
Always Here
Always Here
Posts: 6215
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Double Quotes Bug

Post by mk-soft »

If you need apple script ..

See Link Tips & Tricks AppleScript
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Double Quotes Bug

Post by Piero »

mk-soft wrote: Sun Apr 30, 2023 1:17 pm If you need apple script ..
I'm good with applescript, if you will ever need something…

-- by Piero

on roman2arabic(str)
       set r to 0
       
repeat with i from 1 to (count str)
              set r to r + (item (offset of (item i of str) in "mdclxvi") of {1000, 500, 100, 50, 10, 5, 1}) * (((((offset of (item (i + 1) of (str & "@")) in "mdclxvi@") ≥ (offset of (item i of str) in "mdclxvi")) as integer) * 2) - 1)
       end repeat
end roman2arabic

on arabic2roman(n)
       set r to ""
       
repeat with i from 1 to (count (n as string))
              set r to item (((item -i of (n as string)) as integer) + 1) of item i of {{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}, {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}, {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}, {"", "M", "MM", "MMM"}} & r
       end repeat
end arabic2roman

display dialog arabic2roman(roman2arabic("xvi"))

…but not with all that mess where it's mixed with cocoa, objc and whatever...

Thanks again!
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

So?

Post by Piero »

I'm still waiting for Fred to tell me I'm a Genius!
Obviously I'm kidding: THANKS FRED!
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Perl Example

Post by Piero »

Code: Select all

;   Some RTF text must be on clipboard...

;   Applescript (no problem):
;   display dialog "RTF Clipboard to HTML:" default answer do shell script "osascript -e 'the clipboard as \"RTF \"' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))' | textutil -stdin -stdout -convert html -format rtf"
;   Terminal (no problem):
;   osascript -e 'the clipboard as "RTF "' | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | textutil -stdin -stdout -convert html -format rtf

; Purebasic console (double quotes error):
p$= ~"-e 'the clipboard as \"RTF \"' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))' | textutil -stdin -stdout -convert html -format rtf"
RunProgram("osascript", p$, "", #PB_Program_Wait)
User avatar
mk-soft
Always Here
Always Here
Posts: 6215
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Double Quotes Bug

Post by mk-soft »

RunProgram not start multipli programs like terminal. Bind "|"
-> osascript -> perl -> textutil
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Double Quotes Bug

Post by Piero »

mk-soft wrote: Sun May 07, 2023 11:47 am RunProgram not start multipli programs like terminal

Code: Select all

prog = RunProgram("echo", ~"\"can you get a nicely \"double quoted\" output?\"", "", #PB_Program_Open | #PB_Program_Read)

Output$ = "" : If prog
While ProgramRunning(prog) : If AvailableProgramOutput(prog):Output$ + ReadProgramString(prog) + Chr(13)
EndIf : Wend : CloseProgram(prog) : EndIf : MessageRequester("Output", Output$)
 
Forgive the """indentation""" :)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Double Quotes Bug

Post by netmaestro »

We used to have an eyeroll smiley. Good times.
BERESHEIT
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Double Quotes Bug

Post by Piero »

I had some laughs re-reading this thread after some time passed...
Anyway, to summarize, the problem is:
Runprogram parameter is always considered as """literal""", no way to get results from """complex""" shell commands…
That's a big, BIG limitation…

PS: Fred, you're interesting :oops: :mrgreen:
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Double Quotes Bug

Post by Little John »

netmaestro wrote: Sun May 07, 2023 10:31 pm We used to have an eyeroll smiley. Good times.
Here you go!
Image
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Double Quotes Bug

Post by Piero »

Little John wrote: Wed Aug 02, 2023 4:13 pm Here you go!
Image
Please leave me and Fred alone!
Image
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Double Quotes Bug

Post by Little John »

Piero wrote: Wed Aug 02, 2023 6:24 pmPlease leave me and Fred alone!
Image
Oh well ...
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Double Quotes Bug

Post by Piero »

Little John wrote: Wed Aug 02, 2023 10:42 pm Oh well ...
I'm jealous! :x
User avatar
Piero
Addict
Addict
Posts: 876
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Double Quotes Bug

Post by Piero »

There is a "workaround"!!! (THANKS deseven!!!):
viewtopic.php?p=605503&sid=7aa7f71171f2 ... 1c#p605503
Post Reply