IBLiveMode example needed story detailing scripting
Date:
2002-08-07 15:10:18
From:
psheldon
Evidentally, project builder and interface builder files aren't sufficient to let me see the story behind what makes code work.
I didn't know what object1 etc. were. I might guess that each time I enter an F-Script into the double click LiveMode I specify the next object# source. Is that so?
I couldn't see the script lines. That would have made source and destination clearer in inspector. This confuses me and hints at an emerging understanding. In the MVC model, I believe, F-Script is being used as a controller and there are view objects being associated with scripts specifying actions and outlets.
Under the hypothesis that object# is a script object, nothing goes to the script as an action. But, this jibes with my other aha, "Objects ie. nouns aren't actions ie. verbs". Somehow, being wired from an object containing a method makes a control both able to act and respond. That is surprising and constitutes, thereby, information.
I need more detailing in a column, please. I want to do livemode but right now can't. This is fundamental stuff that will be in hindsight wonderfully obvious.
Showing messages 1 through 5 of 5.
IBLiveMode example needed story detailing scripting
2002-08-09 10:08:25
pmougin
[View]
Note that object# variables are not script objects. In fact they are outlets that allows you to connect from F-Script to “external” object in IB. When you establish a connection from the F-Script window to an other objet in IB (via the IB connection mechanism (i.e. CONTROL+Drag)) then the connection inspector let you assign the target of the connection to one of the object# outlets. Once this is done, the object# variable becomes defined in the F-Script workspace and will evaluates to the connected object (let’s say, for example, a button). THEN, since you now have a handle on the button, you can configure it, from F-Script, the way you like. For instance, supposing you have connected the object1 outlet to a button, you can assign the button a block as target by typing in the live mode F-Script window:
When the button will be pressed, the block will be evaluated and play a beep…
Note that understanding F-Script live mode is not trivial if you don’t master both F-Script basics and IB. I would recommend one to start familiarizing with the F-Script stand-alone application before experimenting more advanced features like live mode in IB.
Phil
thanks, example gave something to chew on
2002-08-10 08:26:50
psheldon
[View]
Here, in guessing a parsing of this statement for meaning, I use my dumb in hindsight gestalt. Object is not action ie. noun is not verb.
Here # means the last statement's objects output, much as in maple computer algebra language % does. In maple I learned a writing "style with %" that helps sequential interactive developement of a compound statement in a >-promt-line of code. I suppose that I will learn a similar style in F-Script.
object1, through connection I made in IB, now stands for the button. I want the (button) control to do something. I have certain syntactic elements in F-Script to build with. I always do something in an object oriented language by sending a message to an object. Thence, I have to set a target object and say what action I want it to take.
In the line of F_script code example, in the language of IB, the button gets associated with an action. In the MVC notion of things the F-Script object is the controller while value: is the action in the controller with # abbreviating.
Yet, here is a surprise that confusing and means an emerging more powerful conceptualization.
You made the syntax of F-Script so it would be wrong to simply write :
object1 setAction: [sys beep] value:
I have some vague memory in ObjC.pdf book about what wiring really means in IB. The memory was vague because the writing was very terse, I believe to hide initially a level of detail that would scare an early reader.
So, now that I am not an early reader, perhaps you can put in words I can swallow why not my proposed abbreviation, ie. why the above syntax doesn't confuse me but would confuse the computer.
;-)
Also, I don't have a clue how to make an outlet. So, what section of your book would I read for actions and outlets. It might give some introduction as to what is going on. Maybe, if console works, the computer would complain to me when I wrote it my abbreviated statement. I'm getting that experimental itch! Good.
;-)
thanks, example gave something to chew on
2002-08-11 04:46:37
pmougin
[View]
In order to configure the button (i.e. object1) we need to provides it with a target (i.e. an object), and the name of the message it must send to the target when clicked (this is the Cocoa target/action paradigm). The Cocoa API require for the "action" message to be a message with one and only one parameter. At run-time, when clicked, the button will send the message to its target, passing itself as the parameter (this allows the target to further interact with the button if needed).
In our case the target is an F-Script block. Our goal is to execute this block when the button is clicked. As you know, in order to execute a block, you send it a "value..." style message (the exact message depends on the number of parameters the block is expecting). Here, we configure the button with the "value:" message name, which is the one that takes one parameter (in the example, our block doesn't make use of this parameter).
Note that "#value:" represent the name of a message. What in Objective-C is called a message selector. So in fact it is (in F-Script) an object, but an object whose job is to represent the name of a message. It is a noun that describe a verb.
The target-action paradigm is described in the Apple Objective-C book, as well as some notions about outlets. I would also recommend you to get the Hillegass Cocoa book (see http://www.bignerdranch.com/Book/).
Phil
thanks, I believe # is F-scripts symbol and have distilled something
2002-08-12 22:12:01
psheldon
[View]
My objC.pdf manual with index didn't mention a #.
I got, p.57 of old objC.pdf manual with index, that a method selector can take a runtime assigned variable as an argument, so I understand why you value implementing F-Script to take something like a literal constant. I've seen constant strings and string variables that were assigned, so I think I got the idea what this #-construct is doing and how its place could be occupied with something more general.
You wrote :
"The target-action paradigm is described in the Apple Objective-C book, as well as some notions about outlets."
I read this, but I need to struggle writing to get it in my heart.
An outlet is an object declared in a controller associated with an IB object. The IB/controller object has methods that the controller can send it as messages, such as to write some text. Now, when I set up such an outlet and its use totally in F-Script and interface builder, I imagine I must exemplify me doing something to get that object to do its method. To get an idea, I give myself an example of pushing a button. That button would run a script by my coding as in your example and in that script the outlet would be assigned to and object by the control drag mechanism. Then I would see the text print.
Am I right?
If I am right, when I am not so tired, I will give myself an exercise doing this in a simple little example program. I shall then write myself a little column, big enough for my own adventure. I know I can talk myself into believing I understand, but only when I try to work out something will I get the ultimate confidence (after some frustration).
I shall consider buying Cocoa book by Hillegass.
Thank you again.
Re: thanks, I believe # is F-scripts symbol and have distilled something
2002-08-14 10:54:48
pmougin
[View]
Basically, what you need is to make the F-Script block a target of the button. Normally, in IB, to make an object a target of a button, you juste control-drag FROM the button TO the object. Here is a somewhat not easy thing to graps with F-Script live mode: the commonly used technique described above is not what you will use to connect a button to a F-Script block! Actually this is a two step process:
First, you let know the F-Script interpreter about the button by control-dragging FROM the F-Script interpreter object TO the button and assigning the button to one of the interpreter outlet (object1 for instance).
Now, you can manipulate the button from within F-Script. This means that you can now type "object1 setTarget:[sys log:'hello'. sys beep]. object1 setAction:#value:]" in the F-Script live mode window. This will establish the block [sys log:’hello’. sys beep] as the target of the button.
object1 setTarget:[sys beep]. object1 setAction:#value:
When the button will be pressed, the block will be evaluated and play a beep…
Note that understanding F-Script live mode is not trivial if you don’t master both F-Script basics and IB. I would recommend one to start familiarizing with the F-Script stand-alone application before experimenting more advanced features like live mode in IB.
Phil