Applescripts Cannot Save Properties...

I have several scripts that a while back just quit saving their own properties when running (they can save properties to other scripts, but their own properties are not being saved).

Since I haven’t been able to find anything on google about this, has anyone else experienced this? Besides a clean re-install of Jaguar, can anyone reccomend any steps to try. (I have fixed permissions and recently reinstalled Jaguar, but to no avail.)

Have you tried recompiling the scripts, or creating new copies by pasting the script into a new window in a script editor? I don’t know if it will help but I think I’d try it before reinstalling OS X.

I have tried both of those. No dice.

I can get them to save properties if

  • I run it out of the script editor’
  • I run it with the OSA menu.

I can’t get them to save properties when

  • Running out of the iTunes script menu
  • Running out of the Entourage script menu.

I tried deleting the iTunes prefs from the library, buth that didn’t seem to have any effect. Still kind of stuck.

Ok, that sounds familiar. I use a program named NetNewsWire and it has a script menu. When I run scripts from its menu, properties are not saved. I spoke to Brent Simmons, the developer, and he said that it was caused by the way he implemented the script menu. He further stated that it could/would be fixed. I suspect that you might be running into the same issue, although it would strike me as surprising that Apple wouldn’t do it right in iTunes. I started writing property values to a file to overcome the issue.

The main thing that bothers me about it is that it worked correctly for a very long time, and then it stopped. And I can’t remember when it stopped working or any changes I made immediately before that.

Sometime tonight in my testing I managed to make it work twice. And then I saved the file again and it stopped again.

I’m going to post a note on the apple boards too to see if that provides any help.

Hi,

Maybe providing more info may help them help you. How are you saving the script? What do you mean by if I run it from the script Editor it works?? You’re saving the properties from another script or changing the properties from another script? Is the script too big to post? I probably got more Qs but watching volleyball!

gl,
Kel.

I have tried saving the script in compiled form (both in the resource fork and data fork).
I am changing the properties for the running script.

Attached is an example script, which should make the default button the button that was previously pressed. It does’t do that for me.

property db : 3
set db to (button returned of (display dialog "Watch the default button change" buttons {"1", "2", "3"} default button db)) as integer

I think that we should start to look in other direction for keeping our properties. In fact i’m now starting to use the ‘defaults’ command with a 'do shell script ’ of course


defaults write com.yourName.appletName '{ "Prop1" = foo;  "Prop2" = bar; }'

Wich is quiet easy to manage. I think, it could be useful to write a library that would manage it.

This looks like it would work well with strings, but more complex data structures might be a problem. It also seems as though it is solving the wrong problem.

depends on what kind of structure you are talking about. It very simple to save a list, maybe a little it harder for a record. You can store in a dictionnary ( a keyword = one value ) , an array ( a list of values), you can also stroe booleans, srings, numbers, ?

jsut try to type ‘man defaults’ in your Terminal and you’ll see.

JB


writePropertyByName("db", 3)
readPropertyByName("db")

on readPropertyByName(thisName)
	set myCommand to "defaults read com.pcs.myApp  "" & thisName & """
	do shell script myCommand
end readPropertyByName

on writePropertyByName(thisName, thisValue)
	set myCommand to "defaults write com.pcs.myApp "" & thisName & "" " & thisValue
	do shell script myCommand
end writePropertyByName

haaaa, you may be wondering about setting the type too :

type : ’ defaults help’ to get all the available formats


writePropertyByName("db", 3,"integer") 
readPropertyByName("db") 
 
on readPropertyByName(thisName) 
   set myCommand to "defaults read com.pcs.myApp  "" & thisName & """ 
   do shell script myCommand 
end readPropertyByName 
 
on writePropertyByName(thisName, thisValue,thisClass) 
   set myCommand to "defaults write com.pcs.myApp "" & thisName & "" " & "-"& thisClass &" "&thisValue 
   do shell script myCommand 
end writePropertyByName