Passing "?" to Script Editor from Safari

Hi all!

I don’t know if I’m reinventing the wheel, but I’ve found a way to pass the character “�” to the Script Editor (you know, the new protocol “applescript://…”). It works only from Safari, we may find a way to do it from other browsers.

You can see a sample here:
http://homepage.mac.com/julifos/assartik/articulos/04.html
(scroll to the last applescript sample and click the disk icon)

Basically, the script is hardcoded into a javascript variable:

var script3 = 'property nombre_del_usuario : ""'+CR+
'if nombre_del_usuario = "" then'+CR+
'set nombre_del_usuario to text returned of �'+CR+
'(display dialog "Por favor, teclee su nombre..." default answer "")'+CR+
'end if'+CR+
'display dialog "Bienvenido, " & nombre_del_usuario'

Where CR = ‘r’
And the script is passed as follow:

SaveScript(script3);
function SaveScript(the_script) {
     window.location.href = "applescript://com.apple.scripteditor/?action=new&script=" + escape(the_script)
}

All this code was thought for other tasks, but I was playing and tried to make it work for the new “applescript://” protocol, so I added the “applescript://” stuff and voil�. :shock:

Also, by the way, if you test the previous script, you will see also that is passes OK the special characters (eg, “�”) ( :shock: again).

Why? Well, the only I know is that the page uses ISOLatin1 characters. Eg:

So, the word “Mam�n” is writen in the HTML page as “Mam�n”, and it does work.

This means that the mentioned continuation character “�” is not written as “�”, but as “�” (an umlaut), which is also the hex “AC”, thought when url-encoded as “%AC” is not recognized as “�”. Just download the html page and take a look yourself.

I don’t know how does it work this phpBBS, but perhaps with a little of investigation we could also use it here on our linx? (though I think we can’t force it to print umlauts and it will allways attempt to url-encode hi-ascii; however, still useful for other purposes…)

Hi JJ,

It will be sweet if you have found a way to overcome this problem. I’m still running Jaguar and the beta version of Script Editor 2. When I click on the disk icon, nothing is transferred to Script Editor. Hopefully this is simply a limitation of the beta. :slight_smile:

– Rob

Great tip, jj! I’ll see if there’s some way I can work it in to CStoMC. (It does work for me, Rob, using Safari 1.2 (v125) and SE 2.0 (v43)).

Jon

Hopefully, Apple will add some bytes to his code and we won’t need workarouds in subsequent releases of the Script Editor/applescript-protocol. :rolleyes:

And here I am on 8.6 trying to keep up with you guys…

Nice work jj… I’m going to make a ‘college try’ to figure out what you’re up to…

But I don’t think I can run that fast. :wink:

Thanks.

Peter B.