Friday, July 20, 2018

#1 2011-03-03 11:59:11 am

fiz
Member
From:: Lausanne, Switzerland
Registered: 2011-03-02
Posts: 849

Multi-docs app structure

Hello!

I used Applescript "Studio" (in fact, XCode 3.2.5 with Applescript tab re-enabled) to create a multiple document application.

The problem is, instead of looking deep into the view hierarchy of IB, I tell my TextView to put itself into a property when awaking from nib.

Is the scope of this property application or document? It seems to be the application (but the property is in the document applescript). Shall I declare myTextView as a local variable?

Regards,
BF.


Bernard

Offline

 

#2 2011-03-03 06:13:44 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2777
Website

Re: Multi-docs app structure

A property is scoped to the script object where it's in.

Offline

 

#3 2011-03-04 03:41:27 am

fiz
Member
From:: Lausanne, Switzerland
Registered: 2011-03-02
Posts: 849

Re: Multi-docs app structure

Hello again, DJ!
And the script is the class, not the instances? Is it possible that all the instances share the SAME property? If I wrote in pascal

type CObject = object(TObject)   (<-- CObject is the class)
var itsName: str255                    (<-- itsName is a class variable)
...

firstObject = new(CObject);       
firstObject.itsName:='First'

secondObject = new(CObject);
secondObject.itsName:='Second'  (<-- each instance has its OWN variable)

But in Applescript, my property seems to be SHARED between instances. If I click on a button of my second window (or my third), it's always the textview of my FIRST window which is modified.

Or does the xib file return the same memory address? Strange, isn't it?
Regards.


Bernard

Offline

 

#4 2011-03-04 06:59:31 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2777
Website

Re: Multi-docs app structure

Don't forget that studio is completely different from any kind of application. A studio application is an empty application where your script send and receive events from or to. For the end user it seems like an complete application but in fact it is an fully scriptable empty application that is managed from script(s), internally or externally.

Read this carefully and will fill out all your answers. It seems that you're pointing to another script object and not creating an instance of the object...

Offline

 

#5 2011-03-04 07:13:11 am

fiz
Member
From:: Lausanne, Switzerland
Registered: 2011-03-02
Posts: 849

Re: Multi-docs app structure

propertyLabel
An identifier, unique within the script object, that specifies a characteristic of the object; equivalent to an INSTANCE VARIABLE.

So why my app always sent "update" to the same text view, even if a NEW document is open with its own text view instance?

Shoud I refer explicitely, like "my myTextView" or "myTextView of me" (equivalent to the SELF keyword?)


Bernard

Offline

 

#6 2011-03-04 09:41:21 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2777
Website

Re: Multi-docs app structure

fiz wrote:

propertyLabel
An identifier, unique within the script object, that specifies a characteristic of the object; equivalent to an INSTANCE VARIABLE.


Exactly, you defined the instance variable in the class and not at runtime (constructor) so every instance of that class will have the same property value. It has nothing to do with sharing it's just giving ever instance variable the same value.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)