WWDC2001 Session 133

Transcript

Kind: captions Language: en good afternoon everybody I'm Chris Espinosa I had the components and scripting group at Apple if you've been to a few developers conferences and the Apple script sessions I should be dulling Lee familiar by now I'm gonna be with you the rest of the afternoon I'm standing between you and Memorial Day weekend so I'm gonna make it crisp I'm going to try to make it clear and I'm gonna make it entirely Mac os10 focused well we're here to talk about today is the yearly update on the status of Apple script primarily focused on Mac OS 10 and the key changes in Mac OS 10 that affect you as scripters and affect you as developers the first session is going to be mostly for scripters and developers the second session will be exclusively for people writing software for Mac OS 10 so if you are a script er you can go play some pinball during the second session and then we'll see you at the feedback forum immediately following I am going to talk in the first session about things we are going to change in the future things we know about in Apple script 1.6 things we know about in Mac OS 10 they were going to be addressing but I'll be dealing with that only briefly there's not a lot of forward-looking promises in this session it's going to be focused primarily on shipping apps and getting your scripts running on Mac OS 10 what you'll learn is the new features of Apple script 1.6 in Mac OS 9 and Mac OS 10 that you can take advantage of what to do about your scripts and scripting additions how to move them across where to put them things like that and how to plan for changes that we expect in future versions but first I want to thank all the developers who ship scriptable applications this year I couldn't fit it all on one screen there are a lot of people that updates to their applications they ship Mac OS 10 versions they ship new code and I really really appreciate you're getting behind the platform and keeping your scriptable applications alive and fresh for Mac OS 10 and as usual we had some version interesting things this year notice would that we didn't do a dot o dot one release I consider that a personal triumph is that most of the stuff we ship was good the first time around we script we shipped Apple script 1.5 in the customer beta for Mac os10 we shipped Apple script one point five point five in the Mac OS 9.1 release and it was a version of the Mac OS 10 version back ported to Mac OS 9 and it had a few problems and when we came out with Mac OS 10 we shipped one point 6 on Mac OS 10 and then shortly at thereafter as a software update for Mac OS 9 I highly recommend that you run Apple script 1.6 if you have Mac OS 9.1 it's really the right version to be running one of the most common problems that we've seen on the on the Apple script lists is people saying oh I run my scripts and my scripting editions aren't there and I get all these Chevron's syntax things in my scripts and the common thing is people have turned off their security extensions one of the things that we did in 1.6 1.5 point 5 was allow the mount valium command to use the keychain and in order to that we created a dependency on the security system extensions a lot of people turn those off that turned off all of scripting editions and we fix that in 1.6 so if you're having problems that your scripts don't run or your scripting editions aren't recognized in 1.5 point in Mac OS 9.1 upgrade to Apple script 1.6 and I'll fix it here are some of the new features that we introduced in one five one five five and one six basically since the last time we were here last year for developers one of the things I'm going to be covering is that we introduced into carbon into carbon live on Mac OS 9 and and into the carbon framework in Mac OS 10 the AE gizmos functionality that Yin's alkie wrote lo so many years ago and all of you have been using as a link library for many years we actually built that into the operating system in 1.5 scripters won't notice it it will have no effect on scripters but it will help developers get their software to Mac OS 10 we added a fix for the double as problem I'll be going into that if you are frustrated with the finder and EBIT choice keys happy if you are frustrated with the problem that when you ask an application get something as something else and you get an error can't coerce we have a fix for you it requires developers to modify their applications but it allows them to do the right thing okay we are fully supporting Unicode text is a first-class data type in Apple script I'll be doing a demo of that that's mainly important when you're using the Mac OS 10 finder either for Mac OS 10 or from scripts running in the classic environment where the Mac OS 10 Finder is the only finder around Mac OS 10 finder returns its file names as Unicode text and if your scripts were expecting standard strings and we're doing operations such as concatenation or text extraction on them it would have failed in 1/5 and 155 now it works in 1:6 because we have fully first-class Unicode text support we added support for packaged apps and packaged scripting additions for Mac OS 10 support for script files that don't have type and creators and have all of their script code in the data fork and that's a Mac OS 10 convention so that you can actually send a script across the internet as a single file without having to bin hex it or compress it or do anything like that and it'll actually work when you get it to the other end and we have a different methodology for dispatching events to scripting editions on Mac OS 10 I'll talk a little bit about that we also fixed some bugs some of these you didn't know about some of these you've relied on and now you have to change I don't think you relied on middle item of an empty list crashing convenient way to crash your machine if you need to but we fix that item zero of a list used to not fail it returned silently now it does fail and so that should help you catch some bugs in your scripts where you're actually trying to get item zero of a list now it will actually fail which is the correct behavior the info for scripting Edition couldn't handle files greater than 2 gigabytes in size now it can files and folders the unit type the text to Unicode text coercion assumed the incoming text was Mack Roman now it looks at what your system script is so if you're running a non English system the Unicode coercion will happen correctly in random numbers if you had large similar large seed values such as the current time as as seconds they would produce similar initial random numbers and then be random after that that disturbs some people because they wanted all the random numbers to be random rather than just the second through n so we fixed that there's a very interesting problem where I guess this I'm gonna cast off commas here one two three four five five hundred thirty six million eight hundred seventy thousand nine hundred and eleven plus one equaled negative five hundred and thirty six million eight hundred and seventy thousand nine hundred and twenty one which is not the correct answer we fixed that and mountain volume didn't look at keychain which some considered a bug we considered it a new feature addition we added that in 1.6 which is what you get in Mac OS ten and what you get when you do the software update to Mac OS 9.1 we fixed some readwrite commands that we broke in 155 we just out now checked in the wrong code and we just had to fix it a problem that had been creeping around for quite a long time was manifesting itself different in different operating system was that if you were displaying the contents of a string and there was a null character and ASCII 0 in there it would display differently on different systems at different times sometimes it did just be blank sometimes it would be a backslash sometimes it would be a large number of garbage characters we fixed it so that it now displays as an ASCII zoo asking null character that you can actually copy and paste and reinterpret so we believe that that's the correct behavior now you will see it it'll look like an empty string in most fonts because most fonts don't have a glyph for the ASCII 0 character but it's actually a string with one character in there which is an ASCII 0 and and if you copy and paste it the right thing will happen we had some crashes in Unicode operations that we fixed as I mentioned before the standard editions in in 155 required the security libraries to be present in the extensions folder and if you'd used extension manager to turn them off your standard editions didn't work we fix that there were occasional inaccurate out of memory errors this had been bugging us for about six years we finally figured out what was going on we think if you see any more of these when a script or an applet stops with an out of memory error when it should have plenty of memory please let us know on the Apple script users list and we'll and give us a reproducible case this only happened because we got one very very reproducible case so we can sit and analyze it for two or three days to figure out what was going on it's something that happened very very rarely and there was a problem with scripts that were compiled on Mac OS 10 if you took them back to the classic environment or to a Mac OS 9 machine they would look only for their Mac OS 10 equivalents they wouldn't look for their Mac OS 9 counterparts so the scripts wouldn't run that was especially problematic if you took a script that targeted the finder you ran it once on a Mac OS 10 system and then copied it back to a Mac OS 9 system it would never reconnect to the Mac OS 9 finder it would try to keep launching the non-existent Mac OS 10 finder on that machine and that script would be pretty much permanently disabled that's fixed in 1.6 so in 1.6 you can take scripts that target say Apple works or the finder or Apple system profiler or QuickTime Player or any other application where there's a 9 and 10 equivalent you can move the scripts back and forth and they'll do the right thing there are some bugs we know about in 1.6 these are things we've found since the introduction of 1 6 that we will be fixing in subsequent versions the info for scripting Edition fails if you target it at a UNIX or an NFS file system don't try it we'll be fixing it the low-level Unicode text to text coercion is broken so that if you get type you Oh texts as an application developer and you try to use the low-level coercion the the Apple Event Manager coercion to coercion to coerce into a type char that will fail if you try to coerce it to a type styled text that will succeed and the type style text is a record one element men of which is the type char so that's your work around you coerce it to type style text course that to a record get the first ID first item of that record which is the character element and then that will be your plain text and we'll be fixing that the mount volume command broke on third-party user authentication modules and that includes UNIX file servers and Windows 2000 AFP servers we're still not sure why it did we think it's something that happened in the Apple share client itself because we didn't change any of the mount volume code in this area we're trying to get to the bottom of that but in the next version we will make sure that mountain volume works on all major AFP platforms the read as list using de limiters is broken so even though we we fix the read/write o sacks there are still a couple of little bugs hanging around readers list using de limiters is one of them and sometimes if you send a first event to an application from a script without launching it first the first event will timeout but subsequent events if you rerun the script it'll work we think that that's a subtle timing problem in the Apple event manager or something that we're doing wrong with noticing whether the application is up or not we're going to address that in a future version here are some new features and these are primarily for developers the AE helpers the support for the double as problem and the Unicode class support I'm going to go over each of these AE helpers was born as AE gizmos it's a quick and easier way to deal with building Apple event descriptor records yen's elf key from the original Apple script team wrote this support library I believe it was something like 1993 or 1994 shifted as object code people have been linking that with their systems and shipping that that object code doesn't link doesn't build anymore you can't use it on carbon systems and developers have wanted another link library or access to the source code or something like that we decided just to build that functionality into carbon into carbon Live for Mac OS 9 and into the carbon framework for Mac OS 10 what do these do a buildin print are a very easy way to go between a textual description of your Apple event and the Apple event itself rather than going through and because an apple event as you know can be a deeply nested structure with descriptors inside descriptors inside descriptors rather than going through and building a descriptor adding it to another descriptor throwing away the original coercing it to another descriptor throwing away the other one adding that to another descriptor throwing it away each time doing a relatively heavyweight handle based memory event what a build does is it takes a textual representation of your event does substitution like a you know printf statement of your actual variables for placeholders inside the text event and then builds the whole descriptor or event in one shot in one operation it's much faster it's much lighter weight it doesn't create nearly as many intermediate copies of things just gets the job done much faster ie print is sort of the converse operation it takes a descriptor record which could be all the way up to an apple event and then spools it out in an reinterpret ibill text form to make an Apple event readable this is very useful in debugging and I'm going to show some examples of that the principle routines are a build desk which builds a descriptor AE build parameters which adds something to an already existing descriptor or a build apple event which takes the appropriate parameters and builds an apple event all in one it's like AE create Apple event but it lets you specify everything you need in one statement and then the converse event is the AE print functionality AE print desk to handle takes a descriptor and a list or record an apple event and it prints it in raw text to a handle which then you can print out or dump in a debug window or something like that this text representation has a syntax all its own and so far the only documentation for it is Yin's as original documentation which is back in the circa 1993 SDKs we're working on updating that but for now if you can find an old copy of that SDK and you can get the original documentation that works we've only made a couple of changes yen's original implementation relied on high ASCII characters curly quotes and Chevron's to encase strings and hexadecimal strings and we've added some straight ASCII alternatives in case you happen to be working in an ASCII preferential development environment the hex delimiter Zoar dollar signs you know dollar signs at the beginning in the end and the quote characters are straight single quotes which you then have to escape but you're grown-up so you can do that for con so the the language has constants it has a special interpretation for four character codes because most events and descriptors are built out of four character codes you can usually do four character codes just by typing the four characters if there's high ASCII or something special in there then you enclose them in single quotes the language will do coercion z' in place if you say four character code perón and then some value it'll apply that coercion before it puts it in the event and so you can do pretty much coercion x' in line in this text descriptor I'll show you a little example of that you can describe lists and records in that the text format and at the bottom you see the substitution language and at sign substitutes and a desk parameter for right in that position a double at a caste that is a type and then an @ sign in parentheses takes a special structure which you have to build a struct for which is a long of the length and then a pointer to the actual data so you can put arbitrary data in as long as you create this this struct which has the long and the pointer to it the length and the pointer to it and then if you have a handle when we can find the length of a handle because well it's a handle you just put in two at signs and then the value of that handle will be put in at that point in the event so here's a basic usage this is how you build a descriptor that says every line in the equivalent of every line of document quote name and quote in it would be that an apple script AE bill desk first takes the the destination desk a pointer to that a pointer to a build error structure which is really useful for debugging this is something that we've added in the carbon version if there's an error we tell you what the error is and what line of your text it occurred on which is which is very helpful for debugging the syntax of this screen string and then you pass it the string and then a variable list of parameters and the string we're passing is first single quote obj single quote which means we're gonna build an object specifier okay and then parens which mean we're going to coerce into an object specifier from something else then inside the parens are braces which means we're going to coerce into an object specifier from a record okay well that makes sense if you're building an object specifier in straight apple event calls that's what you do you build a record and then you coerce it to an object specifier here instead of making three calls we did it in seven characters which is really nice and then we have our four fields of our record the want the from the form and the SEL D and the want is a COI n coerced to a type type that's nice and the form is an IND X course to an enum that exactly what you want and the SEL D is an type AB form absolute position of a ll space and because there's space in there we have to put that in single quotes and then notice the from parameter the the the from is another object specifier and see we're building an object specifier inside an object specifier in one system call that's what makes it fast and the from is another object specifier built pretty much the same way a coercion of a record of a wonda from a format and SEL D and the SEL D is a txt with an @ sign and the at sign is our substitution that means since this is the first at sign that's encountered in the text substitute in the first following parameter in the call and if you look way down at the bottom of the screen the first parameter is doc name okay so that's what it will do is it will take doc name as a pointer to text and it will create a text ie desk or text descriptor for the SEL d so here if you want to build an object specifier with the value in it with a nested object specifier you can do it in one call similarly you can build whole Apple events that way a build Apple event looks a whole lot like AE create Apple event except it takes instead of instead of giving you pretty much an empty apple event that you then have to fill in here's the direct parameter and here are the optional parameters and here are my other attributes you give it the the event class and the event code you give it the information the target information the type and a pointer to what it is in the size of that the flags of what the return flag and the transaction flag and then you pass it a string and this string says basically our direct parameter the quote - - - in quote he is an alias and I'm going to substitute in a handle and that means because the double axe and that means the first parameter following the string had better be an alias handle in that case it is and what this will do is it will build an Apple event with the direct parameter with an alias handle in that and in one call and that saves you two additional calls and a and a dispose of a transitory descriptor and this will make if you're creating Apple events to send yourself using a build and is gonna really speed things up let me show you the first demo on demo one if we could get that up on both screens I have here our venerable simple text project and let me go to where simple text has a event to send an open Apple event I'm not exactly sure what they use it for but I found it in here so I decided to demo it and they do a lot of things they know out all of the descriptors they build then they have to get current process and then created this descriptor and then create an apple event and then put the parameter in is the direct object and then they have to dispose of it later and it it gets to be a lot of work well what we can do is we've got a replacement that uses a helpers here and we can just find all of this and notice what we do here in our replacement is we call AE billed Apple event with the direct parameter and a single @ sign and then the list that we've already got of of things to open so we save a couple of descriptors we save having to dispose them we save building an extra handle it just makes that much easier to implement okay if we could go back to the slides there's another big package in AE helpers called the AE Strings package and the screen's package is a lot of calls for building a deep AE descriptor incrementally little by little and it basically works in an open right close kind of protocol and if you're being nested you open right open right open right right right close close close there are a bunch of calls basically open right and close for each kind of thing you're writing and if you want to use them basically this is what the text this is what the code looks like you open you write your right you open the sub record you're right you're right you're right you're right you're right you close you write some more you write some more you close you close and you're done and this is more efficient than having to get all of the things that you need collected together at one time and then creating a desk and then putting that desk into another desk and then putting that desk into another desk this saves copies especially if you have a streaming model in the first place and if you don't want to make multiple copies of large chunks of information this allows you to stream into a descriptor without having to make multiple copies of large amount of information it's a little more complex it'll be used in more rare circumstances we actually use a lot of this inside Apple script but now it's available to you in the 80 helpers package so let me tell you what this means to you for developers for scripters it doesn't mean anything hopefully it will mean that the applications that you're scripting will work a little better to developers it means that if you've got code that relies on a gizmos you can port it to Mac OS 10 or two-carbon applications on Mac OS 9 without having to carry on that old link library and with the a print facility that I'm going to show you more of a little later it helps you debug because you can actually see what's going on inside your descriptors in a printf function so let's move on to the next one support for the double as problem how many of you have run into this in real life when you ask an application for a script to give you some value as some other type in it it gives you a list of things of that value and then complains that it can't coerce that list into what you asked for fair number have run into that that's because the AZ term is used in two ways in Apple script one it's a binary coercion operator take this and coerce it to that type and second it's used as a parameter to events and when it's used as a parameter to events Apple script isn't really smart enough to say oh the application must have handled that so I'm not going to do an additional coercion it tries to be too helpful it it knows that you want for example the files as file specifications are as aliases so it takes the result and it tries to coerce it to what you asked for even if the result is list and so you get one or two things one is you either get an coercion error or you get a bad coercion for example if you ask for things as strings it's going to take this list and if the list can be coerced to a spring it'll do it which isn't nice if you were asking for the file names of every file and you get one string with all the file names concatenated together so this is primarily troublesome for plural key forms or whose clauses which are really the most useful things because whose clauses let the application do the work without you having to iterate in order to work around this you have to iterate you have to send more events it's much slower and it forced the scripters to write unnecessarily slow loops so we've got a solution and the solution is in your applications if you handled the as parameter all you have to do is to put an optional parameter in the reply of the get data event saying I handled the as parameter an apple script will look at that and say hey somebody handled the as parameter and it won't try to do the coercion again it's actually very straightforward and it's compatible so that if your application doesn't supply at Apple script we'll do it the old way scripts that didn't work will continue not to work and scripts that did use the workaround will continue to work so that if you do this let your scriptures know that you do this so that they won't have to use the workarounds anymore so let me show you how it works once again we're in our simple text application oh no we're not in our simple text application because we have a different application for this to demo this we're using Quinn's vulnerable more OSL and more OSL is a lovely framework for building very scriptable applications and one of the things and let's just show an example of more OSL and run the application and here's a here's a script it makes three new windows and it gets the name of every window as string right well this is a classic double as a double as case or let's say I think that'll work I'm not supposed to see that yet so this makes three new windows window a window B window C and it returns the name of every window as Unicode text but what happened is that more OS L gave me the name of every window as a list of three Unicode text items and then Apple script said oh he wants that list as Unicode text so it concatenated them all into one Unicode text string so when my application has three four windows named CBA and untitled one what I get is a single string that says C be a untitled one that's not very helpful so what we can do is open these add-ins and what we do is right here if this is a get data event and if it has an as parameter we took care of it and so what we do is we basically put the I das the I did as parameter as true into the reply and that's basically all we do let's quit the application and rebuild it and run it again and this time when we run the script you see our result is a list of four Unicode text strings which is pretty much what we wanted we wanted it as four Unicode text so thank you Quinn for providing a great framework so it's really simple if your application handled the ads all you do is put you know I das true in the reply and there you go and we have the slides back what this means to you is you can choose if you did the coercion to let Apple script know that you did it or not what this means descriptors is that applications should improve and you should be able to use fewer workarounds fewer loops and use more applications native capabilities okay now I got some Unicode text there and you saw that the Unicode text all got concatenated together as a string well that's something that didn't happen prior to Apple script 1/6 Unicode class support is something that we added in 1/6 primarily to handle what's going on with the finder the finder 10 now returns all file names as Unicode text one Apple script 143 could take these and it could send them to other applications but it displayed them as data Chevron u txt and then a bunch of hexadecimal it's better than nothing but it wasn't great 1 5 and 155 added some Unicode text support but it was broken in some places and it didn't have any of the concatenation operations it didn't have the substring operations it didn't do anything that you wanted it to do when we realized that if you were running Mac OS 9 scripts on Mac OS 10 and the only finder around was the Mac OS 10 finder and the Mac OS 10 finder always returned unix unicode filenames and your scripts wanted to take filenames and concatenate them and piece them apart and do all these things with them those scripts would break unless we could do full Unicode text so we moved that to high priority and we implemented in 1 6 both 4 9 and 4 10 so unicode strings for the script ur have character word paragraph and text item elements just like strings they have a length property just like strings they have coercion x' to lists record strings style text and number they have the concatenation operator they have a number of comparison operators their comparisons obey the considerations but they actually obey the considerations according to Unicode comparison rules not the styled text comparison rules so less than greater than may be interpreted differently for Unicode text than you would expect it to be for style text especially when it comes to things like case and they support all of the key forms the absolute position the first last middle some every and range characters 1 through negative 1 through negative 2 of Unicode text some character of middle coat Unicode text will pick one out of the middle Chris Neville always wants to do some integer and have that generated random number but that's a different different item so if we could have the demo1 machine up again quit this fine application so here's a script that scripts the finder to get a name and we'll get the class of the filename that's not what I wanted I wanted the class the class of the file name is Unicode text I can get the individual characters of the file name this is a hack here because for some reason the Finder is returning an extra Unicode an extra garbage Unicode character at the end of a Japanese filename that it doesn't return at the end of a non-japanese filename so there's a hack here we haven't figured out what's going on but if this is an this is an English system it's set to English language but if I get the characters of the filename I get them in Japanese in the script editor I can say character one of the file of file name and hello I'm going a little off-road here because I didn't practice this and I get the concatenation of the Japanese character and the English characters so concatenation works she's he saw before range works if I say file1 and I say every word a file name I get the three words of this one get unicode characters so you can see that your scripts that are accustomed to working with strings can work just fine with Unicode text from the finder for scripters the the main effect on you the main effect on scripters is first that your scripts that manipulate finder filenames from 9 will work on 10 even though 10 is returning a completely different data format and that you will now have access to multilingual text regardless of what language your machine is set to you can manipulate and display the text from multilingual file names in the finder even if your system isn't set to that particular language which is a really nice feature what this means to developers is that now that Apple script knows and is fully literate in Unicode you can and should start returning Unicode text as your primary string datatype from whatever application data that you have behind it I strongly recommend that you migrate to Unicode text now that Apple script supports it as a first-class data type and that scripters will be accustomed to using it in their scripts it'll be much more versatile for setting file names let me tell you about some differences between mac OS 9 and Mac OS 10 scripting editions are the first one there are some new features in Mac OS 10 they're actually really great they're going to be hard to get used to but they're really great the scripting editions folders follow the locales model the Mac os10 introduced and what that means is that there isn't just a single system folder there's no unity between you your operating system and your machine anymore okay it used to be when I was a young lad and we invented personal computers that if you had a machine the machine and your environment and the operating system software we're all the same thing okay and that's why there's one system folder on Mac OS 9 but that doesn't work for shared machines and that doesn't work for machines and network environments and that doesn't work for machines that you want to keep running reliably for long periods of time without screwing around with the system software so Mac OS 10 separates those there is a system folder for the machine there's a system folder for the operating system and there's a system folder for each individual user and when you log in as that user you get your own special system extensions and additions and we follow this model and that there are at least three scripting editions folder on every Mac OS 10 system sometimes five the three are slash systems slash library scratch slash scripting editions which is the one the operating system provides and that's the one pre-populated with apple editions and that's where the standard editions are there's slash library slash scripting editions which is common to that machine and which is changeable if you're an administrator you can put new scripting editions in there and they will be available by all users on that machine without having to change what's in your scripting editions folder in your operating system so that if you really want to get back to a clean default machine just throw out slash library slash scripting editions and the OS will be the way it was shipped you don't have to hunt through you know was this a system one or did this was just something I added and then if you've got multiple users on the machine every user has their own in their in their user folder in their libraries folder in their user folder they can have a scripting editions folder and if they populate that with scripting editions those will be available to that user but they won't be available to other users so if you've got a machine that you want to use as a graphics processing workstation sometimes or as a database machine some other times and they have different scripting additions and they might conflict you can have some in one and some in another and just log in as a different user and you get a different set and you can keep conflicting ones apart it's actually a very useful structure the code model for writing scripting additions if you're a developer is different and this is a little problematic on Mac os10 all code must be carbon on Mac OS 9 system code and scripting editions or system code because they can be invoked by any application cannot be carbon and so that means it's technically impossible to write a scripting Edition that will work on both 9 and 10 and so don't even try it if it's just not worth it if you want to ship Mac OS 10 scripting editions you have to take your Mac OS 9 scripting Edition carbonize it package it for Mac OS 10 and ship it for Mac OS 10 and they'll be separate scripting editions for Mac OS 10 can be either the CFM model that you build with code warrior or they can build them be the mach o model that you build with the project builder and they can be flat single file or they can be packaged in in bundles if you went to the application packaging and extensions they're actually packages not out not they're actually bundles not packages because packages are applications but that's a different thing I don't quite understand yet they're packages they are they're not bundles they're packages okay they are packet bundles that are packages okay theoretically you could build a package that had both the classic and the Mac os10 deliverable in it but that'd be kind of useless speak you know it would be helpful for you to upload and download just one copy but the user would have to put it both in their Mac os10 scripting editions folder and in their mac os9 scripting editions folder and so you'd have a copy of a useless scripting Edition in each of the folders you'd have four copies of the code when you only really need to have two it's just not worth it so we don't recommend that if you have old scripting additions you want to migrate to 10 migrate them to carbon and ship them as Mac OS 10 only is the right way to do it access to scripting editions is really interesting I tried to go through this last year and I think I confused more people including myself than I got clear Mac OS 9 in classic really behaved as always classic applications will only have access to classic scripting editions Mac OS 10 scripts will have access to the Mac OS 10 scripting editions in all of the Mac OS 10 scripting editions folders and they can get at Mac OS 9 scripting editions by targeting a Mac OS 9 application with an event so if you send an event from 10 to 9 from a 10 applicant from a 10 script to a 9 application and that event is a scripting addition event it will execute with 9 scripting additions ok which is both important to know if you want to invoke the 9 scripting Edition and important to know if you don't have a tan equivalent of it you know the the scripting Edition will get invoked in that so if you say you know tell application launcher display dialogue display dialogue will happen in the 9 space it'll happen in classic and the display dialogue you'll get is nines display dialogue not tens display dialogue so it'll come out platinum not aqua ok important to know another important thing to know is that Mac OS 10 applications don't execute scripting additions in their own application space in fact most Mac OS 10 applications don't know about scripting additions and so Apple script in Mac OS 10 if it sends a scripting Edition event to an application and the application says I didn't handle that event then Apple script re dispatches the scripting Edition event to the sending application to get executed in the sending applications process so if sorry I'm going back a little bit to execute a scripting edition in nine you got to do two things you got a target a mac os9 application and what doug corns of our group tends to do is he puts launcher in the startup items folder and launcher is a great application because you can target it with scripts it always hangs around it's relatively unobtrusive and it's useful for launching your mac os9 applications in classic and then he uses the using terms from clause to actually target to actually compile the script so basically you have to do a little setup to actually get at launcher you tell the launcher using terms from the real scripting Edition get monitored depth there's something like that and then and an end and this script if you actually run it in ten with classic running it will send an event over to the launcher launcher will execute it in classic it will execute the even a 68k scripting addition and return the result back to your Mac os10 script so if you want to if you want to use your old classic scripting additions for Mac os10 scripts this is the structure that you use to do them on Mac os10 scripting additions aren't loaded in the system heap at startup time because there is no system heap and there basically is no startup time so we can't do that we were thinking of loading scripting additions behind the back of every application but that would burden every application launch time with the scripting additions load time and applications on ten don't need to do more work at launch time we don't want to add another bounce just for us so to make it to make us not have our own bounce for every application applications don't load scripting additions and when we send an application the scripting Edition command if it doesn't handle it then we execute it basically ourselves in the current application context so an application if it chooses to if it's if it's an OS a client if it's going to execute scripts and it would be better off to execute scripting additions in its own context it'll have scripting addition if not we'll just handle it for it the result of the scripture should be transparent and the result of the programmer should be that your application launches faster and that people can send all sorts of scripting additions to your application you just won't handle them you'll never even see them but the scriptor will have the same result let's see how that works so here I've got a couple of scripting additions I guess I can quit this and I'll go to the finder and go to my home directory into my libraries folder and note that I don't have a scripting additions folder here so I have to create one and for now I didn't add a space that's an oversight that we hope to be able to fix and I take a scripting Edition and I drop it in my scripting additions folder so now I have access to that scripting editions terminology and I can run it and it works and what's interesting is that I still have access to scripting editions from all other applications let me go down and see if simple text is still running here so here's simple text here's that script I bet you know didn't know simple texts have this option did you so you can see that simple text has access to that scripting edition too okay now the finder the finder doesn't execute scripts so it doesn't have scripting editions loaded so this opened for access scripting addition in this parse XML scripting Edition commands will be sent to the finder but the finder is gonna say I don't handle these but instead of getting an error event not handled Apple script will just resend it to the script editor the script editor will execute it and you get the right results and if you look at the event log you'll see that you don't even see that Reedus it it thinks it's telling the finder it thinks the finder is executing it but you're the finder is not script editor is you're just getting the right result so what this means to developers is that you should port your scripting editions to carbon in order to get them on Mac os10 and you need to release both separate Mac OS 9 and Mac OS 10 versions of your scripting editions descriptors what this means is you know for optimum benefit you could and should move your scripting Edition calls out of your tell blocks since if they're sent to an application that doesn't understand them they're just going to be reduce patched to the to the scripting script application anyway you might as well move them out of your tell blocks it'll just save an extra event send to the application for that and if you want to target Mac OS 9 editions you need to enclose those in a tell block for the Mac OS 9 edition okay couple more differences in Mac OS 10 that I want to cover before we end and go to questions one is the packages issue Mac OS 10 apps our folders not files as we heard in the bundles and extensions discussion on Friday this is for being able to work on non HFS file systems and being able to transport things over the network without having resource Forks and types and creators and things like that mangled but there's some key differences there because your scripts as scripters probably assume that if you get an application it's a file it's not a file info for will report that the application is in directory if you asked for path to with an application it's going to have a colon at the end and it's going to end in dot app actually it's going to end in dot app colon because that's its real name on the file system okay you are going to see differences between what the real thing is on the disk from what the user sees in the finder now we're going to work on showing you both versions and giving you access to what the truth is and what the user sees we need some help from the finder and from the system in doing that that'll come in in subsequent versions but for now remember that when you use Apple script Apple script will tell you the truth of the file system in that an app is a folder in ends and a colon yNN's and dot app even if it doesn't look like that in the finder paths and extensions files in a we didn't change and we're still using most of the carbon api's for this we didn't change the way that we interpret and show things to the user in Mac OS 10 if you're accustomed to colon separated path names you get colon separated path names so your scripts that parse colon paths will still work if you ask for the finder for name for every disk you're going to get the discs on your desktop and you can start a colon delimited path with those disclaims that's not the way the file system really is though ok the file system really starts at slash and those disks are in slash volume slash something we debated long and hard about whether to give you access to both colon delimited and slash delimited file names and we thought that it was just going to be a total nightmare for scripters to do that so we're maintaining for the file and alias types the colon delimited file name.for and for path to and anything that returns the filename as a string we're going to continue to do that we will probably not ever support slash delimited paths but will support file URLs which I'll talk about in the next session the finder hides file extensions it hides dot app now it will probably hide other extensions in the future info for if you want to do anything in the file system you really need the full name with the extension so if you say tell app simple text we're doing a nice thing by not making you type simple text dot app but the real name of the application is simple text dot app ok path info 4 will tell you that path to info will require that path 2 will tell you that and in future releases will provide you more information on what the file extension is and whether the file extension is showing or not in order to enable your scripts to do the right thing we are using extensions more in Apple script as was talked about in the presentation on Wednesday extensions are not required but if present they'll be interpreted so if you get a script across the internet that has no type no creator but ends in dot scpt and you double-click it the script editor will open and it will read it as a compiled script so scpt is our compiled script file dot AppleScript is our uncompelled raw text of apple script and i assume that there will be other dot script files that may or may not be opened in the script editor for other types and we have two special types for terminologies Oh sax is a scripting Edition and dot AS dictionary is for anything else that has an apple script dictionary whether or not it has code attached to it for now if the user wants the extension on it the user has to add the extension manually we don't add any extensions automatically as the system evolves to allow extensions to be added automatically if the user desires that we'll take advantage of that but for now if we don't put one on automatically if the user wants one they can use it and the script editor will continue to set the type and creator of new files it creates so that those files can be used on a Mac OS 9 system and the Apple script 1.6 the Mac OS 9 version will also understand files without typing Creator but only an extension so let me tell you what we're working on before we close and go to go to questions our number one priority is getting more Apple applications scriptable ok Apple script itself we think is pretty good we offered a solid product it offers high degree of compatibility with Mac OS 9 it's reasonably bug free but it's the sound of one hand clapping until you can script the finder and the Preferences and mail and connect to the internet and choose printers we don't think Apple script is done on Mac OS 10 and so we're continuing to work on those things we think now the loss of network tap 11 C is a big hole we are working on that that looks very good for the short term future is getting networked Apple events back in we want a more smoothly integrate with features of Mac OS 10 paths and extensions are one and you know the other capabilities of Mac os10 that allow you to say execute things in the terminal let me just show you because this is a little hack that somebody put together but hacks are good right as I told you there are separate folders in each domain and there's a components folder in your library domain and you can take for example a new OS a component and just drop it in your slash library slash components folder and when you run the script editor you have multiple component multiple items here in your pop-up so you have more than one OS a language but this isn't mark alder it's JavaScript this is something called bundle shell and I can type PS - ax for example and get a list of the processes running on the machine this is actually bundle shell this is a cheap little demo which just takes the script and execute it from the UNIX command line and takes the resultant pipe it pipes it back just to prove it's Unix there we go there's your password file back to the slides please so that's what I mean by more integration with Mac OS 10 and then there are two perennial projects that I've been talking about forever and we're still working on as soon as they stop revving the OS so we can you know sit and work on our own code for a while rather than court we'll get through these but a plug-in model for applications so that your applications can more easily support plugins and for Apple script it's so we can extend things like adding a full Unicode class without having to go into the bowels of Apple script and hack everything ourselves and then full object models support for lists records and strings and other classes because we we know that scripters are really confused by using the object model in applications but they can't delete a character from a string for example so in summary Apple script and Mac OS 10 is pretty useful it's pretty reliable it's got everything that the nine version has got it works pretty well we lack the scriptable applications on the Apple side and we're getting good scriptable applications on the third-party side we're continuing to add new stuff to Apple script we're not just sitting still with the implementation but we are evolving it as we get a chance to and we're trying to do so in a compatible way so that your scripts continue to run Mac OS 10 and classic versions will stay in sync for a while while you are migrating your solutions from 9 to 10 we will continue to make sure that your scripts can run in either environment there will be some point in the future where we'll discontinued 9 support but that's in the distant future not in the near future and the Mac OS 10 version will support new features in in idiosyncrasies of the Mac OS and that will only be in the Mac OS 10 version so we'll start to diverge a little we're not going to imbue 9 with all sorts of 10 like features but we will make sure that 9 and 10 remain somewhat parallel there's another session coming up in about half an hour which is the building Apple script application session if you are writing a scriptable application or writing an OS a client that session is for you if you are a script er go out and get a soda play some pinball and we'll see you at the feedback forum at 5 o'clock which will be in room C which is right over there across the hall ok I would if you have questions I'm always available I'm the middle guy our technology manager is Jason yo who was across the hall across the street actually doing Darwin presentations right now and our esteemed marketing guy salsa goin as always the apple script implementers and Apple script users lists are great places to get advice from other scripters or programmers and I frequent the developers the implementers list quite a bit and Chris nibble is on the users list quite frequently as well you