Hi there - I have been been trying to get my head around Applescript and xcode for days now and just dont seem to be getting anywhere at all - I even have a degree in Computer Information systems and have in the past coded in C++ and Java.
All I want to do is to have a button that is pressed by the user and a progressbar that increments by 1 until the number 8 is reached. Easy you would have thought !!!
I CANT DO IT – I have searched all the apple sites etc. and there is just no comprehensive ref guide that is simple and informative for me to work though
Am I going mad, I am not lazy I have realy have been goin mental.
. After all this time I have the following code:
on clicked theObject
tell window of theObject
set content of slider "slider" to 1
end tell
end clicked
great except I dont have the knowledge to get any global variables going on !!!
In IB, I created a horizonal slider with 9 markers and set its minimum to 0.0 and its maximum to 8.0 (values are specified as reals, not integers, but I imagine you can use integers and AppleScript will coerce them to reals, so that’s probably not a problem).
property currentValue : 0.0
on clicked theObject
set currentValue to currentValue + 1.0
set content of slider "theSlider" of window "theWindow" to currentValue
end clicked
Note that there’s no provision in my code for what happens when the slider is all the way to the right; when I kept clicking, nothing happened, but I didn’t get any errors either.
I found AppleScript Studio difficult to get anywhere with, at first; but I spent lots of time fooling around with “plain vanilla” AppleScript – that is, with the language itself, outside of any GUI (except for the extremely limited palette of dialogs provided by the Standard Additions).
As I periodically came back to give AppleScript Studio another try, I found it less daunting every time; the more familiar I’ve become with it, the easier it is to either guess what to try or figure out where to look to find documentation or examples.
Since global variables and properties are bread and butter to “plain vanilla” AppleScripters, I already knew how to use them by the time I found myself confronted with the need to store values in an AppleScript Studio script outside of event handlers.
Keep banging your head against the wall! It does get easier.
Thanks for your help - it has just got me to the next level ! I thought this would be an easy cut off handling routine:
property currentValue : 0.0
on clicked theObject
set currentValue to currentValue + 1.0
if currentValue < 9 then
set content of slider "slider" of window "window" to currentValue
else
set currentValue to 0
set content of slider "slider" of window "window" to currentValue
end if
end clicked
now I just need to get the display of the value of the slider
There must be a ref somewhere that tells me all of this ?
on clicked theObject
tell slider "slider" of window "window"
if its content is its maximum value then
set its content to 0
else
set its content to (its content) + 1
end if
end tell
end clicked
You can find anything about object’s terms (such as “maximum value”) in Xcode’s dictionary. Must be somewhere a menu item called “Open Xcode dictionary”, or you can double-click the “AppleScriptKit” located somewhere in your project; and you could also drop Xcode onto your favorite script editor’s icon.