refine record properties

Hi,
i know that properties want to be called by name and not as reference. But thats actually my problem. Some hints ?


tell application "AppName"
set rec_ls to properties of item 1 of my_file
set item 11 of rec_ls to "test" #{new_annot:"test"}
end

Hi,

in almost all cases it’s not necessary to access a property via the property record.
In a record an item can only be identified by key.
Try this


tell application "AppName"
set rec_ls to properties of item 1 of my_file
set new_annot of rec_ls to "test"
end

Hi StefanK

naa.my fault, sorry. Better i post some example to illustrate what i mean. I’m able to set the content of record 11, but apparently in a list only. Also Applying the modified list to the contents of every record of the original properties list gives no results.

tell application "iView MediaPro" to tell catalog 1
	set rec_ls to (annotations of media item 1 as list)
	set item 11 of rec_ls to "test" -->which is record 'source'
	set annotations of media item 1 to rec_ls
end tell

return rec_ls

(*
tell application "iView MediaPro"
	get annotations of media item 1 of catalog 1
		--> {caption:"", annotation writer:"", event date:"", categories:{}, keywords:{}, headline:"", instructions:"", author:"", author title:"", credit:"", source:"", product:"", city:"", state:"", country:"", transmission:"", primary category:"", copyright:"", status:"", event:"", location:"", people:{}, url:"", creator address:"", creator city:"", creator state:"", creator post code:"", creator country:"", creator phone:"", creator email:"", creator URL:"", scenes:{}, subject codes:{}, genre:"", usage terms:"", country code:""}
end tell

--Ergebnis:
--{"", "", "", {}, {}, "", "", "", "", "", "test", "", "", "", "", "", "", "", "", "", "", {}, "", "", "", "", "", "", "", "", "", {}, {}, "", "", ""}
*)

This is dangerous. Records are unordered, and the order of items when they are coerced to lists is undefined. It’s particularly dangerous when getting records from apps, because the properties provided can vary.

Dear Mr. Shane Stanley
thank you for pointing out my mistakes.
As an amateur user of Applescript with no programming background, i probably create often similar dangerous situations without being conscious of it. How would you proceed if you where in me ? from the step you see me now ?

i remember some older episods on Panther:
:rolleyes:
there, i ran into kernel panics every 2-3 months. Btw, it was a really unstable Os. I never had such problems using Tiger and up.

regards
Jo

Just address the properties directly. If it is read/write, then:

tell application "XYZ" 
 set whatever to "test" -- assuming whatever is a writeable property
end tell

However, I don’t have iView MediaPro, but I wonder if what you’re really after might be something like:

make new annotation at media item 1 of catalog 1 with properties {caption"Blah", ...}

I’m just guessing there, though.

Dear Mr. Shane,
i solved my problem from earlier, by calling properties directly, like the way you suggested. You’re right to rest in the context- and sorry that i deviate from my original scope, but i meant lastly:
.maybe i’m ready for a next step in writing code. Do i have a chance to jump into Applescript-Object-C coding with my experience ?

To be honest, it’s a fairly steep initial learning curve regardless. But all it really requires from an AppleScript point of view is that you understand the basics.