Friday, November 24, 2017

#1 2009-09-09 11:29:46 am

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Hi! Beginner here!

Hi I have been scripting in 10.5 since I converted to Mac big_smile last summer. I always meant to start AppleScript Studio but I hadn't the scripting skills till just before 10.6, I never imagined they would axe it! lol lol But I still want to make proper AS apps. I would like to extend some of my scripts on my imadrichard iDisk public folder, if you wanna look, especially my text editor (v2 on iDisk but I have a better v3 here but not compatible with other home folders... yet). I can just about work the Interface Builder except I can't link buttons etc. to script, my script doesn't seem to work in the AppleScript editor after building, I don't understand the bits you get in a new project, something to do with starting and ending so I just delete them (don't need to tell me that's asking for trouble). Quite plainly... Help!

All help greatly appreciated.

Model: iMac bought last year.
Browser: Safari 4
Operating System: Mac OS X (10.6)

Offline

 

#2 2009-09-09 03:36:56 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: Hi! Beginner here!

I had a try at that PartOne thing, didn't work, I did exactly what it said, even copied the script in the end. No use.

Offline

 

#3 2009-09-09 03:44:04 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: Hi! Beginner here!

There is a GUI building video at the top of this page that might help.

There are five tutorials in the unScripted section as well.

-hth

Offline

 

#4 2009-09-10 09:30:19 am

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: Hi! Beginner here!

They are nice videos and stuff but it doesn't explain anything. I see "'s" everywhere and sub routines that have no on statement like the makefirstresponder one, the only new bit I understand is the sub routines linked to actions... kind of... but then there are things on statements which are never called in script like the nib one.

Last edited by Richard (2009-09-10 02:59:16 pm)

Offline

 

#5 2009-09-10 10:44:24 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: Hi! Beginner here!

Richard wrote:

They are nice videos and stuff but it doesn't explain anything.


Really? You went through all five tutorials and feel they do not explain anything?


Richard wrote:

I see "'s" everywhere and sub routines that have no on statement like the makefirstresponder one, the only new bit I understand is the sub routines linked to actions... kind of... but then there are things on statements which are never called in script like the nib one.


makeFirstResponder
From the tutorial. I'm not sure how to explain this any better. We are sending the message "makeFirstResponder" to the NSWindow "aWindow."

Select the Text Field on Application Launch
If you haven't noticed, each time we launch our application the mouse is in the text view and not in the text field. There are a few things we are going to do to fix this.

1. Add a property as an outlet to our window
2. Connect our property in IB using [control + drag] from the "blue cube" to our window.
3. Use a Window method "makeFirstResponder_()" and give it our text field as a parameter

Applescript:


-- add this below the other property declarations
property aWindow : missing value

-- add this as the last item in the awakeFromNib handler
aWindow's makeFirstResponder_(textField)


The "'s" are one way of sending messages to the object with the "s." There are several ways to send messages and each developer tends to gravitate to one. Although you will see all of these methods scattered out through different posts and code samples.

Lesson five goes into more detail on how to convert Objective-C to AppleScriptObjC so you might want to look it over again. I will add some more tutorials with more detail on the basics.

Example.

Applescript:


script MyAdder
   on addNums(num_one, num_two)
       return num_one + num_two
   end addNums
end script

tell MyAdder to set a to addNums(5, 10)

tell MyAdder
   set b to addNums(5, 10)
end tell

set c to MyAdder's addNums(5, 10)
set d to addNums(5, 10) of MyAdder


{a, b, c, d} #=> result {15,15,15,15}

If none of this is making sense, and that's ok, we've all been there, then may I suggest you go through the beginner tutorials on unScripted. I have a list of sources for learning AppleScript here.

Regards,

Craig

Offline

 

#6 2009-09-10 03:09:10 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: Hi! Beginner here!

OK, sorry, I should have mentioned that I haven't read all of tutorial 1 because I stopped reading where I got stuck and then decided to have a quick go at tutorial 2 because it was a different example which I thought would be different, it helped slightly. I stopped a "Build and go" because I did exactly what you said but it failed to build, even with copy/pasted code from here. Before more questions, why didn't it build?

Offline

 

#7 2009-09-10 03:14:47 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: Hi! Beginner here!

Zip up the project and email it to me. Hard to tell without looking at it.

craigw@macscripter.net

Offline

 

#8 2009-09-10 04:10:35 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: Hi! Beginner here!

Weird, I trashed it after it didn't work so I did it again now to send (I thought I did it the same) but this time it worked. hmm Oh well... I'll do the rest of the tutorial now. Thanks anyway.:D:D:D

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)