Page 2 of 2

Re: Double Quotes Bug

Posted: Sun Apr 30, 2023 1:17 pm
by mk-soft
If you need apple script ..

See Link Tips & Tricks AppleScript

Re: Double Quotes Bug

Posted: Mon May 01, 2023 8:35 am
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!

So?

Posted: Fri May 05, 2023 11:10 pm
by Piero
I'm still waiting for Fred to tell me I'm a Genius!
Obviously I'm kidding: THANKS FRED!

Perl Example

Posted: Sun May 07, 2023 3:50 am
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)

Re: Double Quotes Bug

Posted: Sun May 07, 2023 11:47 am
by mk-soft
RunProgram not start multipli programs like terminal. Bind "|"
-> osascript -> perl -> textutil

Re: Double Quotes Bug

Posted: Sun May 07, 2023 6:40 pm
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""" :)

Re: Double Quotes Bug

Posted: Sun May 07, 2023 10:31 pm
by netmaestro
We used to have an eyeroll smiley. Good times.

Re: Double Quotes Bug

Posted: Wed Aug 02, 2023 3:38 pm
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:

Re: Double Quotes Bug

Posted: Wed Aug 02, 2023 4:13 pm
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

Re: Double Quotes Bug

Posted: Wed Aug 02, 2023 6:24 pm
by Piero
Little John wrote: Wed Aug 02, 2023 4:13 pm Here you go!
Image
Please leave me and Fred alone!
Image

Re: Double Quotes Bug

Posted: Wed Aug 02, 2023 10:42 pm
by Little John
Piero wrote: Wed Aug 02, 2023 6:24 pmPlease leave me and Fred alone!
Image
Oh well ...

Re: Double Quotes Bug

Posted: Wed Aug 02, 2023 11:09 pm
by Piero
Little John wrote: Wed Aug 02, 2023 10:42 pm Oh well ...
I'm jealous! :x

Re: Double Quotes Bug

Posted: Thu Aug 10, 2023 3:39 pm
by Piero
There is a "workaround"!!! (THANKS deseven!!!):
viewtopic.php?p=605503&sid=7aa7f71171f2 ... 1c#p605503