![]() |
Quote:
I.e. after the dialog is dismissed, control gets back to the next line. That is where you want to tell AppleScript to go home - it's all over. |
I'm not sure what the proper terms for an AS 'return' would be. I imagine a conditional 'end tell', but I got compilation errors when I tried that. But I know what you mean from what little C I've learned.
I removed the "OK" button from the dialog and that worked. Code:
tell application "Finder" |
Don't know how to trap the "Cancel" problem - the AppleScript isn't doing it and don't have my own PC server running.
You might think about some means of escaping from the "repeat until .." loop too; suppose the damned server won't mount for some reason - the test will never be satisfied. The "with timeout" structure doesn't work within the AS itself - it applies when you are concerned that a "tell" segment will fail when the "told app" fails to respond. AppleScript and its Additions are not very good at timing in ticks or finer scales and I don't know what OSAXen you have. Another way is to increment an integer and stop it when it reaches some large number, i.e. limit the number of loops allowed. An Afterthought Since Applescript isn't good at timing, you might just put a delay of 2 seconds in the repeat until loop so it will only execute every 2. Otherwise the loop will run as fast as it can and eat CPU time. |
Quote:
return will return to the caller of a function. I believe that a simple 'return' at the top level in a script will exit the script. O'Reilly book sample chapter on AppleScript control-flow keywords: http://www.oreilly.com/catalog/aplsc...pter/ch07.html |
Sweet! Thanks! Trying my hand at XCode now to build a cocoa app to do this (yeah right, good luck yellow! :))!
|
Does this work any better?
Code:
property user : "bruce"The last line is an example of how to size a Finder window. If you're trying to determine a good size, move the window yourself, then run this statement in a new Script Editor window: Code:
tell application "Finder" to return bounds of front Finder window |
There are a couple of scripts here that give the full works with regard to window sizes etc. They are compiled ones for some reason. The scripts are called 'Tile Front Windows' and 'Open Tandem Browser Windows'
If the only reason for wanting to use AS Studio is to allow the user to enter their user name/passwords, bear in mind that 'normal' AS will allow you to enter stuff into the script with 'display dialog' Code:
set response to display dialog "What is the unladen weight of a sparrow?" default answer "African or European"On the other hand, if yellow just wants to use AS studio because he can ...... go for it! |
Thanks, I'll look into both of those last 2 posts when I hit work today.
I actually bit the bullet and picked up an AppleScript book last night at my local book gigantomart. I figured I better start somewhere, I can always be begging others to do my work for me. I think that I want to use ASS (heehee!) mainly because it'll give me a nice polished looking app that I can use to gather username, domain, the user's view preferences, and save all that in a .plist file. Then give them 3 1d10t buttons at the bottom of the app window that allows them to mount/open their Home, Public Shared, and Private Shared. One polished app, incorporating all that they need. I'm also hoping that I can figure out how to get this to log to /var/log/system.log. Definitely not necessary, but something I'd like to learn. |
yellow, would you be using OS X 10.3?
|
Yes.. all the Macs this is destined to end up on will be running Panther (10.3.8).
|
Normally those commands should work on other versions too though... Its all pretty much standard OS X applescript stuff.
|
Quote:
|
Quote:
|
Cool, thanks! I'll definitely look into it.
|
Is there an example anywhere of Cocoa Bindings in use in an AppleScript App?
|
Quote:
Frist, in Xcode's main menu, goto Project > Edit Active Target 'name', then, in the resulting window, choose Info.plist Entries > Simple View > Basic Information. Fill in the Identifier box. This will be used by the user defaults system. Apple's programs typically use com.apple.name. You might enter something like "yellow.OpenFolders" (sans quotes). Now, move over to Interface Builder. Let's say you have a text box where the user enters the domain. With said text box selected, open the Info panel and choose Bindings from the menu. You can bind any of the listed properties. For now, click on "value". Enter a name in the "Model Key Path" box, and press enter. (The "Bind" checkbox will automatically be checked.) This is the key that will be stored in the preference list (e.g. yellow.OpenFolders.plist). Of course, you will also use this name to get the key's value out of the preference list. We'll assume you entered "Domain". While we're in Interface Builder, you need to set "File's Owner" to trigger the "will finish launching" event handler. To do this, select "File's Owner" from the instances tab, open the Info window, and choose AppleScript from the menu. Expand the Application list, and check "will finish launching". Assign this event to a script in the box below. [Still with me? :)] Move back over to Xcode. Open the script that will handle the "will finish launching" event. Assuming you have nothing else in this handler, it needs to look like this: Code:
on will finish launching theObjectLet's see how things work so far. Build and run your application. The domain text box should contain the default value you entered in the "will finish launching" handler. Change the value of the text box, then quit and relaunch the application. The text box should contain the new value you entered. Well, that should be enough for now. Thanks for reading! |
Quote:
|
Just an update..
As I read through the AppleScript book, I've learned a little bit and added some stuff and cleaned up some stuff. Just though I'd update with where I'm at currently (if you care :)):
Code:
tell application "Finder" |
Looking rather pro, yellow, for a guy who just picked up AS the other day for the first time.
And Guardian34 - thanks for the very cogent explanation. Now it's clear to me what "binding" is. In languages like SuperCard, handlers are part of GUI objects themselves. From your explanation and Apple's, Cocoa Binding is the means of linking the pieces of the GUI to the handlers that deal with them, i.e., creating the event loop linkages for you in essence. Have I got the general picture? Having saved your explanation, I'll try it (and I'll bet yellow will too). Thanks. |
Quote:
Quote:
|
| All times are GMT -5. The time now is 06:03 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.