Cocoa scripting will generate default keys for property and element attributes and for commands, if you do not specify them. For a property, it capitalizes each word of the propertyâs name except the first word, then removes any spaces. For an element, it specifies the plural of the element type. For a command, the default is NSScriptCommand
apart from that, the handler parentheses are missing
Thanks for the input, I had a question earlier in this thread regarding parenthesis, and by the answer I got from Shane, I figured I couldnât use parenthesis with a command that is supported with terminology.
Edit
I asked the question in post #9, and Shane answered it in post #11, (page 1 ).
The motivation, is of course to have the terminology load with the use script clause, so I wonât have to use a script object in order to utilize the commands, but can use them like I can with a scripting additions command.
For the record, the script bundle is named corelibrary, the sdef file is named corelibrary.sdef, the name in the bundle tab is corelibrary, and the id is net.mcusr.corelibrary. ASOBJC is enabled, and the sdef document a valid sdef/xml utf-8 document.
your sdef should have an empty command tag if it is really empty, I guess it uses libxml to parse the file because in libxml there is a difference between and . So you sdef should look like:
Not when you use your own scripting definition, parentheses are not needed then.
I have done what you have done, and I have also tried with/without use AppleScript version â2.3â
But it just doesnât work. (I also added a title tag to the dictionary.)
Restarting ScriptEditor and closing bundles with various earlier attempts , and âtest scriptsâ, made sure of that there wasnât any conflicting terminology around, and it worked!
Thanks
I did add "use AppleScript version â2.3â " in addition to following DJ Bazzie Wazzieâs receipe to the point.
Iâm a bit surprised by this. The reason is because I went back and looked at the sdef for ASObjC Runner, which does this very thing for several commands, and they all work fine.
Itâs surprising that you have to use an âempty tagâ though, when there is nothing to be put inside the command tag.
Hindsightly I guess I had saved some hours if I had started out with AppleScriptObjC Explorer in the first place. I managed to wreak havoc with AppleScript Editor over the course, and I actually had to restart it, not only close the script bundle, which I had figured up front I never would have, as long as I didnât add the script bundle to the dictionary library of AppleScript Editor. Now things are working great, and thanks for all your help and patience!
Edit
The main take away from me besides using âempty tagsâ, when there wasnât any content to put within has been the cycle:
I think Iâll just use what you call an âemptyâ tag, when there are nothing like direct-parameter and other parameters inside the command block. Itâs a good rule of thumb, particularily, when Shaneâs AsObjC Explorer creates such sdef definitions for such commands.
I think I may have really littered Script Editor in the process, but now the process is controllable again.
When there is no dictionary added to the library of AppleScript Editor, no script in the editor , that uses the library bundle I am editing in the editor; then edititing the sdef, saving the bundle, adding the handler, then compiling the bundle, and re-saving it works well!
This even works if I have to change words in the command or parameters, due to having used some reserved word, like âusingâ for instance, and re compile, works like a charm now!
Yesterday, behind the same machine I couldnât compile your sdef file and when changed it into <command > I could compile it. When I set it back to tag it wouldnât compile again just to make sure that it was the problem. And again when set to style it would compile. Because I was working with libxml2, and it does have a difference between these two (the check for empty tag will return true for <command > and will return false ), I assumed there is a difference for script libraries as well. But today I wanted to get the same âerrorâ again and everything compiles just fine, even without extra saving. So I guess it has to do with some caching or something in the background.
Einstein once said: âInsanity is doing the same thing over and over again and expecting different results.â. Iâm in doubt if Iâm going insane or Mavericks :D.
The only messing with XML I do is when I read in an existing sdef, in which case I turn all type attributes into elements, because it makes the interface simpler. And of course the table handles things like escaping reserved characters.
You young 'uns have it easy In the old pre-Mavericks days, the slightest mistake in an sdef would usually mean at least quitting and relaunching your editor. After much begging, sdef file modification dates are now compared and caches cleared if necessary.
I believe what ruined it totally for me yesterday, was having several scriptbundles, with almost the same terminology, and some driver scripts as well. I guess I managed somehow to trash the cache, but I am not looking back into it.
Next time I get serious issues, Iâll restart the Script Editor and take it from there.
Thanks for the tidy xml command Shane, I didnât know it convert tags!
I was having cache issue. It seems that the running instance of AppleScript loves to cache script libraries and itâs definition files. Even when I remove the a script library and then create a new one with the same specs the errors will be thrown on my screen knowing it shouldnât give an error in the first place. I need to logout and login again in order to make the script compile again. I will look into this if Yosemite have these cache issues as well.
In short: The first steps I posted previously is very important you do them correctly the first time! If not, there is no way you can make the scripting definition to load properly and youâre forces to start over or re-login to the system. I will take these steps in side note in the tutorial as well.
FWIW, one of the biggest caching gotchas is that the modification date check is done with the app or library, not the sdef file. Changing a file inside a bundle doesnât always change the bundleâs modification date. Even saving over an existing bundle doesnât always change the bundleâs modification date, either. So you need to think about doing something like touching the library.
I was trying to learn how to make my own library based on this tutorial.
I didnât succeed, and I would like to have your help.
My goal is to make a library which I can call directly, just using
use script "Luciano_Library"
, AND NOT using the:
use myLib : script "Luciano_Library"
For example, in the tutorial, I could not find the " Inside the drawer youâll see the contents of your bundle. Inside this drawer there is a checkbox to enable AppleScriptObjC, "
What I am asking if someone can make a library for me using the script below, just 3 subroutine of different types (alias, integer, text) as a bundle, which would include also:
a simplified version of the ScriptingDictionary.sdef
Info.plist
So from this I can learn and make what I need.
Or as alternative to direct me to a place where I can learn how to do it.
Thanks a lot
Subroutines for the library:
on BeepAlert(numberOfTimes) -- integer
beep numberOfTimes
end BeepAlert
on WriteTotextFile(fAlias, textToWrite) -- alias, text
set fileDescriptor to (open for access fAlias with write permission)
try
set eof fileDescriptor to 0
write textToWrite to fileDescriptor -- as «class utf8»
close access fileDescriptor
on error errMsg number errNbr
close access fileDescriptor
error errMsg number errNbr
end try
end WriteTotextFile
on listToString(theList, theDelimiter) -- List, text
set theBackup to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelimiter
-- Perform the conversion
set theString to theList as string
set AppleScript's text item delimiters to theBackup
return theString
end listToString