Accessing properties in sub stack fields

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing properties in sub stack fields

John
Hi,

   I was hoping that someone could explain what is going on.  I have a main stack with multiple sub stacks all of which use the main stack’s menu bar.  In the menubar group I have a mouseDown handler to update the menus before they are shown.  The sub stacks have fields which may, or may not, have a property “noType” with a value of “true”.

   In the mouseDown handler in the menuBar group, the following does not work:

put the noType of the focusedObject && the focusedObject into msg

I can see that the focusedObject is correct even though the value of the property is not shown.  If I place this into the mouseDown handler I get the expected result:

put line 1 of the openStacks into theTopStack
put the selectedField into theSelectedField
put word 2 of theSelectedField into theSelectedFieldNumber
put the noType of field theSelectedFieldNumber of stack theTopStack into msg


  Why does the first one line scrip not work and the longer four line script work?

Thanks in advance,
John
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Accessing properties in sub stack fields

Kay C Lan
Try:

 put the noType of (the name of the focusedObject) && the focusedObject
into msg

The reference returned by fucusedObject is not in the format that is used
for the syntax of a custom property. You need to shorten it by referring to
just 'the name'.

HTH

On Thu, Oct 9, 2014 at 9:39 AM, John <[hidden email]> wrote:

> Hi,
>
>    I was hoping that someone could explain what is going on.  I have a
> main stack with multiple sub stacks all of which use the main stack’s menu
> bar.  In the menubar group I have a mouseDown handler to update the menus
> before they are shown.  The sub stacks have fields which may, or may not,
> have a property “noType” with a value of “true”.
>
>    In the mouseDown handler in the menuBar group, the following does not
> work:
>
> put the noType of the focusedObject && the focusedObject into msg
>
> I can see that the focusedObject is correct even though the value of the
> property is not shown.  If I place this into the mouseDown handler I get
> the expected result:
>
> put line 1 of the openStacks into theTopStack
> put the selectedField into theSelectedField
> put word 2 of theSelectedField into theSelectedFieldNumber
> put the noType of field theSelectedFieldNumber of stack theTopStack into
> msg
>
>
>   Why does the first one line scrip not work and the longer four line
> script work?
>
> Thanks in advance,
> John
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Accessing properties in sub stack fields

John
Kay,

   I gave it a try but it didn’t work.  Digging in a bit deeper it gets a bit more mysterious.  It appears as if “the name of the focusedObject” and "the focusedObject" refer to different objects. I expanded what goes to the message box by using the following:

   put ">" & the noType of (the name of the focusedObject) & "<" & return & return & the name of the focusedObject & return & return & the focusedObject into msg

I get this in the message box:

><

card "Main"

field id 1012 of group id 1003 of card id 1002 of stack "Ohm's Law Solver" of stack "/Users/john/Documents/iPhone_Collection/LiveCode 2.0/EE Tool Kit 2.0/EE Tool Kit.livecode”


    This is weird in that the main stack has a card named “main" which is not related to the field returned as the last item in the put statement.  If I modify (and simplify) this a bit to:

put the long name of the focusedObject & return & return & the focusedObject into msg

I get this in the message box:

card "Main" of stack "/Users/john/Documents/iPhone_Collection/LiveCode 2.0/EE Tool Kit 2.0/EE Tool Kit.livecode"

field id 1012 of group id 1003 of card id 1002 of stack "Ohm's Law Solver" of stack "/Users/john/Documents/iPhone_Collection/LiveCode 2.0/EE Tool Kit 2.0/EE Tool Kit.livecode”


   I can’t think of a reason why the “the name of the focusedObject” and "the focusedObject" refer to different objects.

Thanks,
John


On Oct 8, 2014, at 7:40 PM, Kay C Lan <[hidden email]> wrote:

> Try:
>
> put the noType of (the name of the focusedObject) && the focusedObject
> into msg
>
> The reference returned by fucusedObject is not in the format that is used
> for the syntax of a custom property. You need to shorten it by referring to
> just 'the name'.
>
> HTH
>
> On Thu, Oct 9, 2014 at 9:39 AM, John <[hidden email]> wrote:
>
>> Hi,
>>
>>   I was hoping that someone could explain what is going on.  I have a
>> main stack with multiple sub stacks all of which use the main stack’s menu
>> bar.  In the menubar group I have a mouseDown handler to update the menus
>> before they are shown.  The sub stacks have fields which may, or may not,
>> have a property “noType” with a value of “true”.
>>
>>   In the mouseDown handler in the menuBar group, the following does not
>> work:
>>
>> put the noType of the focusedObject && the focusedObject into msg
>>
>> I can see that the focusedObject is correct even though the value of the
>> property is not shown.  If I place this into the mouseDown handler I get
>> the expected result:
>>
>> put line 1 of the openStacks into theTopStack
>> put the selectedField into theSelectedField
>> put word 2 of theSelectedField into theSelectedFieldNumber
>> put the noType of field theSelectedFieldNumber of stack theTopStack into
>> msg
>>
>>
>>  Why does the first one line scrip not work and the longer four line
>> script work?
>>
>> Thanks in advance,
>> John
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Accessing properties in sub stack fields

Peter Haworth
In reply to this post by John
I think this is an example of LC not always dereferening things as
expected, especially when custom properties are involved.

I've had similar issues in the past and in fact have just had another one
where the following results in a runtime error:

put the cMyProp of (line 1 of the recentCards) into tVar

The following works around the error:

get line 1 of the recentCards
put the cMyProp of it into tVar

As to why the name of the focusedObject and the focusedObject return
references to two different objects, I think you should enter a QCC report.


Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>

On Wed, Oct 8, 2014 at 6:39 PM, John <[hidden email]> wrote:

> Hi,
>
>    I was hoping that someone could explain what is going on.  I have a
> main stack with multiple sub stacks all of which use the main stack’s menu
> bar.  In the menubar group I have a mouseDown handler to update the menus
> before they are shown.  The sub stacks have fields which may, or may not,
> have a property “noType” with a value of “true”.
>
>    In the mouseDown handler in the menuBar group, the following does not
> work:
>
> put the noType of the focusedObject && the focusedObject into msg
>
> I can see that the focusedObject is correct even though the value of the
> property is not shown.  If I place this into the mouseDown handler I get
> the expected result:
>
> put line 1 of the openStacks into theTopStack
> put the selectedField into theSelectedField
> put word 2 of theSelectedField into theSelectedFieldNumber
> put the noType of field theSelectedFieldNumber of stack theTopStack into
> msg
>
>
>   Why does the first one line scrip not work and the longer four line
> script work?
>
> Thanks in advance,
> John
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Accessing properties in sub stack fields

John
Pete,

   Thanks for the insight.  The issue with the focusObject seems to be fairly nuanced and perhaps based on execution speed and platform.  There is another message thread with the subject "Is this a bug or am I missing something?”, that seems to indicate that the focusedObject is changing value during the execution of a single line of script.  I will file a bug report if appropriate when that thread winds to a conclusion.

Thanks,
John


On Oct 9, 2014, at 9:24 AM, Peter Haworth <[hidden email]> wrote:

> I think this is an example of LC not always dereferening things as
> expected, especially when custom properties are involved.
>
> I've had similar issues in the past and in fact have just had another one
> where the following results in a runtime error:
>
> put the cMyProp of (line 1 of the recentCards) into tVar
>
> The following works around the error:
>
> get line 1 of the recentCards
> put the cMyProp of it into tVar
>
> As to why the name of the focusedObject and the focusedObject return
> references to two different objects, I think you should enter a QCC report.
>
>
> Pete
> lcSQL Software <http://www.lcsql.com>
> Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode