Can't set AppleScript format properties

According to the SD dictionary I can set color, size and font. But this fails:

tell application "Script Debugger"
set prps to AppleScript format 1
    tell prps
	set its size to 16
    end tell	
end tell

Returns:
Result:
set size of AppleScript format 1 to 16
–> error number -10000

error “Script Debugger got an error: AppleEvent handler failed.” number -10000

Hey Phil

I haven’t tried these with Script Debugger 6 yet, but knock yourself out.

-Chris

--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/02/01 13:10
# dMod: 2016/07/13 03:51
# Appl: Script Debugger
# Task: Get AppleScript Formats (font & style).
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Script_Debugger, @Formats
--------------------------------------------------------------------------------

set asFontPropList to {}

tell application "Script Debugger"
   
   set asFontPropNameList to name of AppleScript formats
   
   repeat with i in asFontPropNameList
      tell AppleScript format i
         set end of asFontPropList to {name, font, size, its color}
      end tell
   end repeat
   
end tell

asFontPropList

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/02/01 13:11
# dMod: 2016/07/13 03:52
# Appl: Script Debugger
# Task: Restore AppleScript Formats (font & style).
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Script_Debugger, @Restore, @Format
--------------------------------------------------------------------------------

set asFontPrefRec to {{"New text (uncompiled)", "Menlo-Regular", 14, {32767, 0, 32767}}, {"Operators, etc. (+ & ,)", "Verdana", 14, {0, 0, 0}}, {"Language keywords", "Verdana-Bold", 14, {12272, 12272, 12272}}, {"Application keywords", "Verdana", 14, {0, 0, 65535}}, {"Comments", "Menlo-Regular", 14, {0, 0, 0}}, {"Values (numbers, data)", "Verdana", 14, {0, 0, 0}}, {"Variables and subroutine names", "Verdana", 14, {16383, 32767, 0}}, {"Strings", "Menlo-Regular", 14, {0, 0, 0}}, {"Command names", "Verdana-Bold", 14, {0, 0, 65535}}, {"Parameter names", "Verdana", 14, {0, 0, 65535}}, {"Classes", "Verdana-Italic", 14, {0, 0, 65535}}, {"Properties", "Verdana", 14, {27745, 1206, 54284}}, {"Enumerated values", "Verdana-Italic", 14, {27745, 1206, 54284}}, {"Addition Command names", "Verdana-Bold", 14, {0, 5672, 45210}}, {"Addition Parameter names", "Verdana", 14, {0, 5672, 45210}}, {"Addition Classes", "Verdana-Italic", 14, {0, 5672, 45210}}, {"Addition Properties", "Verdana", 14, {17401, 5415, 45324}}, {"Addition Enumerated values", "Verdana-Italic", 14, {17401, 5415, 45324}}}

tell application "Script Debugger"
   
   repeat with i in asFontPrefRec
      
      set {_name, _font, _size, _color} to contents of i
      
      tell AppleScript format _name
         set its font to _font
         set its size to _size
         set its color to _color
      end tell
      
   end repeat
   
end tell

--------------------------------------------------------------------------------

I can’t reproduce that here. Can you check that the specified font is available?

Ah, good call. It DOES work on 10.11. It’s only on Sierra it doesn’t work.

The font is Courier (though I think it should be Menlo), but I’ll have to check later if that’s the reason or its some other kind of bug that needs filing.

Thx.

Hhhmm, no something funny’s going on. Now I can’t get it to work in 10.11 either.

I reset all the Fonts & Colors back to default using the ‘Factory Defaults’ button.

Then I tried to reapply my settings from a saved file. Got the same error as above.

Then I tried to run that script at the top of this thread just to change the size to 18 from 12 of the first Format. Error’d again.

My ‘save’ script looks like this:

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

set formatRecord to {}

tell application "Script Debugger"
	set theFormats to every AppleScript format
	repeat with i from 1 to count of theFormats
		set theFormatProps to properties of item i of theFormats
		set end of formatRecord to theFormatProps
	end repeat
end tell

set the_file to ((path to desktop as text) & "formats.txt") as «class furl»
try
	set dataStream to open for access the_file with write permission
	set eof of dataStream to 0
	write formatRecord to dataStream starting at eof as list
	close access dataStream
on error
	try
		close access the_file
	end try
end try

Then my read script looks like this:

set the_file to ((path to desktop as text) & "formats.txt")
set theFormatRecs to (read file the_file as list)

tell application "Script Debugger"
	repeat with i from 1 to count of theFormatRecs
		set theProps to theFormatRecs's item i
		tell AppleScript format i
			
			set its font to theProps's font
			set its size to theProps's size
			set its color to theProps's color
		end tell
	end repeat
end tell

But it fails on the ‘set its font to theProps’s font’ line.

tell application "Script Debugger"
set font of AppleScript format 1 to “Courier”
–> error number -10000
Result:
error “Script Debugger got an error: AppleEvent handler failed.” number -10000

Any ideas?

I quit and relaunched SD6, and whatd’ya know.

I guess there was something cached in memory that refused to budge.

I Hate those kind of problems. Anyway, this works for me and is kind of fully to watch with several script windows open:

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

tell application "Script Debugger"
	repeat with aFormat in AppleScript formats
		set aFormat's size to (aFormat's size) + 10
	end repeat
end tell


tell application "Script Debugger"
	repeat with aFormat in AppleScript formats
		set aFormat's size to (aFormat's size) - 10
	end repeat
end tell