Re: Loss of formatting preferences
Re: Loss of formatting preferences
- Subject: Re: Loss of formatting preferences
- From: Steve Mills <email@hidden>
- Date: Wed, 28 Oct 2015 14:25:36 +0000 (GMT)
- X_v_e_cd: 736f2c4cd6317a799a854427acf6acff
- X_v_r_cd: a6cfcf70be3e0b571730ffb7cc9227ac
I was losing formatting prefs a while back, got sick of this obvious bug, and wrote a couple scripts to save and load the actual formatting settings to/from a file. I figured this was better than just saving the plist, since the plist can have lots of other unknown things it in, and the formatting was the only thing I noticed going wonky.
Here they are if anybody wants them. Oh, they were written for Script Debugger, since Script Editor doesn't publicize the pref:
Save Formatting:
tell application "Script Debugger"
tell application "System Events"
set p to (path of documents folder) as alias
end tell
set savePath to (choose file name with prompt "Name the file for saving the format data." default name "Saved AS Formatting.txt" default location p)
set f to open for access savePath with write permission
set eof f to 0
set fmts to AppleScript formats
set AppleScript's text item delimiters to "-|-"
repeat with fmt in fmts
set c to color of fmt
set t to {name of fmt, font of fmt, (size of fmt) as text, (item 1 of c) as text, (item 2 of c) as text, (item 3 of c) as text}
set t to t as text
write t & return to f
end repeat
close access f
beep
end tell
Load Formatting:
tell application "Script Debugger"
tell application "System Events"
set p to (path of documents folder) as alias
end tell
set readPath to (choose file with prompt "Choose the file with format data." default location p)
set f to open for access readPath without write permission
set AppleScript's text item delimiters to "-|-"
repeat while true
try
set t to read f before return
if t is not "" then
set t to every text item of t
set nam to item 1 of t
set fnt to item 2 of t
set syz to (item 3 of t) as number
set rr to (item 4 of t) as number
set gg to (item 5 of t) as number
set bb to (item 6 of t) as number
try
tell AppleScript format nam
set its properties to {font:fnt, size:syz, color:{rr, gg, bb}}
end tell
on error err
display dialog err & return & return & "You probably need to quit and relaunch Script Debugger. It has a bug that causes this error if you've opened the Prefs window and edited any of the formats." buttons {"Cancel"} default button 1
end try
else
exit repeat
end if
on error
exit repeat
end try
end repeat
close access f
beep
end tell
Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden