Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Classic Macs and Mac OS > AppleScript Droplet Needs Testing

AppleScript Droplet Needs Testing
Thread Tools
Speckledstone
Dedicated MacNNer
Join Date: Apr 2002
Location: Chicago
Status: Offline
Reply With Quote
Apr 29, 2002, 01:20 PM
 
I was reading a 'hack', posted at ResExcllence, that explained how to protect an Extensions Manager Set using ResEdit.

Protect An Extension Manager Set

Instead of using ResEdit, I wrote a script that does the same thing. Please test it and give me some feedback.

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>(*This droplet will change a Read-only Extensions Manager Set to an Editable Extensions Manager Set and vice versa.*)
on open these_items
tell application <font color = red>"Finder"</font>
try
repeat with current_file in these_items
set item_info to info for current_file
if (file creator of item_info = <font color = red>"7INI"</font>) then
if (file type of item_info = <font color = red>"RSET"</font>) then
set the file type of current_file to <font color = red>"ESET"</font>
else if (file type of item_info = <font color = red>"ESET"</font>) then
set the file type of current_file to <font color = red>"RSET"</font>
end if
else
display dialog <font color = red>"The item, \"</font>" & (name of item_info) & �
<font color = red>"\"</font> is not an Extensions Manager Set. Nothing will be done to this file." buttons �
{<font color = red>"OK"</font>} default button <font color = blue>1</font> with icon <font color = blue>1</font>
end if
end repeat
end try
end tell
end open</font>[/code]

Also, does this post belong in the Classic Mac OS Forum?

Thanks
     
AppleScript
Forum Regular
Join Date: Feb 2001
Status: Offline
Reply With Quote
Apr 29, 2002, 02:40 PM
 
Your code crashes the Finder if anything dragged onto it is not an Extensions Manager set. Use this:

on open (A)
tell application "Finder"
set C to {}
set D to {}
repeat with B from 1 to (count A)
--try
set C to C & (item B of A as file specification)
--end try
end repeat
repeat with B from 1 to (count C)
if (item B of C as string) does not end with ":" and creator type of item B of C is "7INI" then
set D to D & item B of C
end if
end repeat
repeat with B from 1 to (count D)
if file type of item B of D is "ESET" then
set file type of item B of D to "RSET"
else
if file type of item B of D is "RSET" then
set file type of item B of D to "ESET"
end if
end if
end repeat
end tell
end open

(144)
     
Speckledstone  (op)
Dedicated MacNNer
Join Date: Apr 2002
Location: Chicago
Status: Offline
Reply With Quote
Apr 29, 2002, 04:11 PM
 
Thanks for the feedback!
I'm an AppleScript novice, so it'll take me a little while to figure out your version. More than likely, I'll have some questions.

Originally posted by AppleScript:
<STRONG>Your code crashes the Finder if anything dragged onto it is not an Extensions Manager set.</STRONG>
What OS did you test it with? I tested it in 9.1 and had no problems.
     
AppleScript
Forum Regular
Join Date: Feb 2001
Status: Offline
Reply With Quote
Apr 29, 2002, 05:54 PM
 
9.22.

(145)
     
Speckledstone  (op)
Dedicated MacNNer
Join Date: Apr 2002
Location: Chicago
Status: Offline
Reply With Quote
Apr 29, 2002, 07:14 PM
 
Are there subtle differences in scripting for OS 9.2.2? I upgraded (to 9.2.2) and ran into many instances where the Finder quit while I was running my scripts. I didn't find any benefits to 9.2.2 so I went back to 9.1. (I run 9 exclusively, no X - yet)

Are there any books you recommend? I've got "AppleScript For Dummies" by Tom Trinko, it's good for a beginner like me, except it's getting a little dated. I've also got "AppleScript In A Nutshell" by Bruce Perry, I haven't had a chance to read it cover to cover, but it tends to go 'over my head' quite a bit.
     
C.J. Moof
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status: Offline
Reply With Quote
Apr 29, 2002, 08:45 PM
 
Yes, there are differences. I've had scripts break with the 9.1 to 9.2.x upgrade- very annoying.

I find macscripter.net a useful resource- I've gotten answers from the BBS there before, and it's a great source of osaxen.
OS X: Where software installation doesn't require wizards with shields.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:57 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,