communicating between stacks
Posted: Sat Sep 15, 2012 8:44 pm
Hi, I am having a problem passing information between two stacks (well, maybe more than that but lets start there). The scenario is I am trying to implement a properties window similar to how properties are set in the IDE.
The mainstack has button A.
I open a properties window with "go stack properties as palette" which is a substack
The substack has field B
I would like the value from field B in the substack to set a custom property in button A of the mainstack.
The following line of code works but....
set the cproperty of btn "button A" in stack "my_hard_coded_stack_name" to fld "this field"
Its all hard coded and is not very generalizable to other objects I may want to use the same substack with (other buttons for example). Also, the stack name happens to contain the version number so each time I change the version number I would have to change this line of code.
I have tried (in the card script) :
set the cproperty of btn "button A" in the mainstack of me to fld "this field"
but I get an error "can't set property". This was just a random attempt. I understand that a card does not have a "mainstack" property so I tried moving the code to the stack with no better luck. (the script is triggered by closing the palette stack). The error in this case was "error in object expression".
Anyway, I am sure this doable since the property windows in the IDE seem to do something similar with palette windows I am presuming are implemented as substacks. It would be interesting to hear ideas on how to do this.
Second, I noticed that when I "go stack properties as palette" that the code in the calling routine continues to execute. Is this the way it is supposed to work? I was hoping to be able to set some properties AND be able to respond to the new values in the same script but if it is going to open the palette window and then continue executing the code I am not sure how I am going to do that. Perhaps an example might explain.
If I want to set the label of the button I could just write
ask "Please enter a new name" and the answer (new label name) is in it.
However if I want to set a whole bunch of properties it seems to me you might want to open a form, collect all the value, close the form and then operate on the result. So, call a new window/substack as a palette, get the values, close the palette/properties window and then respond to the new settings. However, if my codes says "go stack properites as palette" and then the next line says "set the label of me to "new name" but we don't even have the new name yet how is that going to work? So there is something fundamental in the use of the "go" command that I am not understanding. I would have thought "go" interrupts the execution of the current handler in some way but it appears not to.
So, those are the primary problems I am facing... (a) how to get a field in a substack to communicate its value to a custom property in a mainstack and (b) how to get the execution of a script to pause when I "go to" a substack (similar to how it pauses when you "go to" an ask dialog).
Thanks
PS Relatedly, is there a command I can use in the msg box that would list all of the properties of an object in LC? Something like "list the properties of button X" or "list the properties of card Y"??
Thanks again
-- mark
The mainstack has button A.
I open a properties window with "go stack properties as palette" which is a substack
The substack has field B
I would like the value from field B in the substack to set a custom property in button A of the mainstack.
The following line of code works but....
set the cproperty of btn "button A" in stack "my_hard_coded_stack_name" to fld "this field"
Its all hard coded and is not very generalizable to other objects I may want to use the same substack with (other buttons for example). Also, the stack name happens to contain the version number so each time I change the version number I would have to change this line of code.
I have tried (in the card script) :
set the cproperty of btn "button A" in the mainstack of me to fld "this field"
but I get an error "can't set property". This was just a random attempt. I understand that a card does not have a "mainstack" property so I tried moving the code to the stack with no better luck. (the script is triggered by closing the palette stack). The error in this case was "error in object expression".
Anyway, I am sure this doable since the property windows in the IDE seem to do something similar with palette windows I am presuming are implemented as substacks. It would be interesting to hear ideas on how to do this.
Second, I noticed that when I "go stack properties as palette" that the code in the calling routine continues to execute. Is this the way it is supposed to work? I was hoping to be able to set some properties AND be able to respond to the new values in the same script but if it is going to open the palette window and then continue executing the code I am not sure how I am going to do that. Perhaps an example might explain.
If I want to set the label of the button I could just write
ask "Please enter a new name" and the answer (new label name) is in it.
However if I want to set a whole bunch of properties it seems to me you might want to open a form, collect all the value, close the form and then operate on the result. So, call a new window/substack as a palette, get the values, close the palette/properties window and then respond to the new settings. However, if my codes says "go stack properites as palette" and then the next line says "set the label of me to "new name" but we don't even have the new name yet how is that going to work? So there is something fundamental in the use of the "go" command that I am not understanding. I would have thought "go" interrupts the execution of the current handler in some way but it appears not to.
So, those are the primary problems I am facing... (a) how to get a field in a substack to communicate its value to a custom property in a mainstack and (b) how to get the execution of a script to pause when I "go to" a substack (similar to how it pauses when you "go to" an ask dialog).
Thanks
PS Relatedly, is there a command I can use in the msg box that would list all of the properties of an object in LC? Something like "list the properties of button X" or "list the properties of card Y"??
Thanks again
-- mark