How to store .applescript text files on web server so that the encoding is correct?

@tempelmann - Here is the code that (I think) responds to your suggestions:

https://mendelson.org/AppleScriptPublisher.html

I created it with the code that you see on the page itself. The code should open in Script Debugger when you click on the link at the foot.

(My changes have an -- emendelson comment)

Also, the very first dialog, which translates to “Run the script with the script open in the editor.”, should be rephrased to make clear it must be Script Editor, not e.g., Script Debugger.

Ahh - I see @emendelson has already done that :slight_smile:

Shall I insert the translations, thereby make it a full-english version? The link to the original is there for those who rather prefer that.

I think there’s no need to add all the markings where you made edits, and even include the original. With the link to the original at the top anyone who really wants to see the changes can use a text compare tool, which displays the diffs much better, while your version makes it harder to read without any benefit for an English reader. Just mention that you made changes at the top, and that should be enough.

Please do! And please feel free to remove my self-identifying comments.

1 Like
  1. Most of my automation Scripts are mede for Script Editor. You can easily modify to support Script Debugger. Original script is made for making WordPress post.

  2. This script is made to be called from Script Menu.

  1. There is some variation scripts
1 Like

Are you sure you can use your script with Script Debugger as the one holding the to-be-printed script? When I changed pName to use SD7 (“com.latenightsw.ScriptDebugger7”), it failed with errors (running your script in SD7 works fine). Have you tested this with SD8 (which I don’t have a license for yet, because I’m happy with 7, which I use still on High Sierra)?

•Update•

I had to replace

tell current application

with

tell application id pName

Then at least one issue went away. But there’s also an error when I set pName for SD7, with the term set curLang to name of language of aInfo (it seems that SD7 doesn’t support “name of language …”, I think).

Everyone, here’s the updated version of Piyomaru’s script, in English:

http://files.tempel.org/Various/AppleScriptPublisher_by_Piyomaru/AS%20Publisher%20v19%20(EN).html

@Piyomaru I have also fixed a few small issues, such as the one with the tell current application and added a Reveal button to show the html file in Finder.

For curLang just use “AppleScript”.

But, here’s something else that doesn’t work with scriptDebugger:

         
         set textList to every attribute run of front document
         set textList_ref to a reference to textList
         
         set colorList to color of every attribute run of front document
         set colorList_ref to a reference to colorList

This is what the beginning of the attribute run for the run handler in this script looks like:

", "on", " ", "run", "
", "	", "set", " ", "pName", " ", "to", " ", "\"com.apple.ScriptEditor2\"", " ", "-- Apple's Script Editor", "
	", "--set pName to \"com.latenightsw.ScriptDebugger7\" -- Script Debugger 7 (gives an error when run)", "
	", "--set pName to \"com.latenightsw.ScriptDebugger8\" -- Script Debugger 8 (not tested)", "
	
	", "using terms from", " ", "application", " ", "\"Script Editor\"", "
", "		", "tell", " ", "application", " ", "id", " ", "pName", "
", "			", "if", " (", "count", " ", "every", " ", "document", ") = ", "0", " ", "then", "
", "				", "display dialog", " ", "\"Run this “AS Publisher” 

I’m trying to figure out if there is a ScriptDebugger equivalent.

We can detect each AppleScript’s lexical elements by its color by using OSAScript functions.
We can get NSAttributedStrings data from AppleScript file.
It may grow 300 or 500 line AppleScript.

Enjoy!

Interesting… For now, I have a script that opens the current SD script in Script Editor. I could use that then run this script.

Could you possibly post that? Sounds very useful…

EDIT: Here’s a probably incompetent attempt to do that:

tell application id "com.latenightsw.ScriptDebugger8" -- Script Debugger.app
	tell document 1
		if file spec is not missing value then
			save
		else
			display dialog "Script must be saved first."
			return
		end if
	end tell
	set posixPath to path of document 1
end tell

tell application id "com.apple.ScriptEditor2"
	open posixPath
end tell

I don’t think that’s what @Piyomaru intended - it seems his publisher can also handle JavaScript, hence one should not limit it this way.

Just a little code “critique”: It’s not smart to use application id "com.latenightsw.ScriptDebugger8" if it could also run in earlier SD versions. I think it’s better to use application "Script Debugger" here.

You’re right. I was being cautious because I only have SD8 here.

1 Like

True, but, I don’t think ScriptDebugger can, so in the context of ScriptDebugger, “AppleScript” should be fine.

This is what I’ve been using:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set whichWindow to 1
tell application "Script Debugger"
   tell current document of script window whichWindow
      
      set sdScriptModified to its modified
      set sdScript to its source text
      set sdSavedFile to its file spec
   end tell
end tell


tell application "Script Editor"
   if not sdScriptModified then
      open sdSavedFile
   else
      set seDocument to make new document at beginning
      tell seDocument
         set its text to sdScript
         compile
      end tell
   end if
   activate
end tell