stumped: set script of buttons at runtime

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

stumped: set script of buttons at runtime

Emilio Gagliardi
Hi All,
I've been battling this problem for a few days and have no idea where  
to look next.  Originally I thought it had to do with global variable  
issues between stacks.  However, after MUCH hair-pulling it appears  
the problem has to do with setting the script property of buttons  
dynamically ...or so I think...Keep in mind the following code works  
perfectly in development.  That is, the last line of the mouseUp  
handler in the hidden defaultButton says "answer the script of me".  
In development, after all the buttons have been created, clicking any  
of the buttons generates a dialog box and the appropriate script.  In  
standalone mode, the script of all the dynamically created buttons is  
empty...even the "answer" command on the last line on makeButtons  
returns empty


on makeButton buttonText

   set the style of the templateButton to "Button"
   set the label of the templateButton to buttonText
   set the visible of the templateButton to false
   set the width of the templateButton to BUTTON_WIDTH
   set the height of the templateButton to BUTTON_HEIGHT
   set the opaque of the templateButton to false
   set the textAlign of the templateButton to "center"
   set the threed of the templateButton to false
   set the showborder of the templateButton to false
   set the autohilight of the templateButton to false
   set the textFont of the templateButton to "verdana"
   set the textSize of the templateButton to "16"
   set the location of the templateButton to DEFULT_LOCATION

   lock messages
   create button buttonText
   unlock messages

   set the script of button buttonText to the script of button  
"defaultButton" of card "defaultBlock"
   set the location of it to getNextButtonLocation()
   set the myHome of it to the location of it

   set the visible of button buttonText to true
   answer the script of button buttonText

end makeButton

All the buttons are exactly the same except for their label.  They  
all have the same functionality so i store the script for the buttons  
in a button whose visibility is set to false.  In development mode  
everything works perfectly.  All the buttons appear, they all contain  
the script from the hidden button, and they all use their respective  
scripts as intended.  However, if I open the stack using the "go"  
command from within another stack, the above makeButton command does  
not set the script property of the buttons and hence none of them  
work.  If I set the visibility of the original hidden button to true,  
it works fine.  So for some reason, setting the script of a button at  
runtime does not seem possible.  Does anyone know what I'm doing  
wrong here??

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

Re: stumped: set script of buttons at runtime

Eric Chatonet
Hi Emilio,

As you say:

> However, if I open the stack using the "go" command from within  
> another stack, the above makeButton command does not set the script  
> property of the buttons and hence none of them work.

I guess it's a "defaultStack" issue: your script does not find the  
button "defaultButton" of card "defaultBlock" because this button is  
located in another stack.
Try something like button "defaultButton" of card "defaultBlock" of  
stack "defaultStack"
Hope this helps.

Best Regards from Paris,

Eric Chatonet.

> Hi All,
> I've been battling this problem for a few days and have no idea  
> where to look next.  Originally I thought it had to do with global  
> variable issues between stacks.  However, after MUCH hair-pulling  
> it appears the problem has to do with setting the script property  
> of buttons dynamically ...or so I think...Keep in mind the  
> following code works perfectly in development.  That is, the last  
> line of the mouseUp handler in the hidden defaultButton says  
> "answer the script of me".  In development, after all the buttons  
> have been created, clicking any of the buttons generates a dialog  
> box and the appropriate script.  In standalone mode, the script of  
> all the dynamically created buttons is empty...even the "answer"  
> command on the last line on makeButtons returns empty
>
>
> on makeButton buttonText
>
>   set the style of the templateButton to "Button"
>   set the label of the templateButton to buttonText
>   set the visible of the templateButton to false
>   set the width of the templateButton to BUTTON_WIDTH
>   set the height of the templateButton to BUTTON_HEIGHT
>   set the opaque of the templateButton to false
>   set the textAlign of the templateButton to "center"
>   set the threed of the templateButton to false
>   set the showborder of the templateButton to false
>   set the autohilight of the templateButton to false
>   set the textFont of the templateButton to "verdana"
>   set the textSize of the templateButton to "16"
>   set the location of the templateButton to DEFULT_LOCATION
>
>   lock messages
>   create button buttonText
>   unlock messages
>
>   set the script of button buttonText to the script of button  
> "defaultButton" of card "defaultBlock"
>   set the location of it to getNextButtonLocation()
>   set the myHome of it to the location of it
>
>   set the visible of button buttonText to true
>   answer the script of button buttonText
>
> end makeButton
>
> All the buttons are exactly the same except for their label.  They  
> all have the same functionality so i store the script for the  
> buttons in a button whose visibility is set to false.  In  
> development mode everything works perfectly.  All the buttons  
> appear, they all contain the script from the hidden button, and  
> they all use their respective scripts as intended.  However, if I  
> open the stack using the "go" command from within another stack,  
> the above makeButton command does not set the script property of  
> the buttons and hence none of them work.  If I set the visibility  
> of the original hidden button to true, it works fine.  So for some  
> reason, setting the script of a button at runtime does not seem  
> possible.  Does anyone know what I'm doing wrong here??

----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        [hidden email]/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------

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

Re: stumped: set script of buttons at runtime

Klaus major-k
In reply to this post by Emilio Gagliardi
Hi Emilio,

> Hi All,
> I've been battling this problem for a few days and have no idea  
> where to look next.  Originally I thought it had to do with global  
> variable issues between stacks.  However, after MUCH hair-pulling  
> it appears the problem has to do with setting the script property  
> of buttons dynamically ...or so I think...Keep in mind the  
> following code works ...
> ...
> and hence none of them work.  If I set the visibility of the  
> original hidden button to true, it works fine.  So for some reason,  
> setting the script of a button at runtime does not seem possible.  
> Does anyone know what I'm doing wrong here??

you are doing nothing wrong actually!
You just have been hit by the "Scriptlimits", sorry :-/

See the "Note" in the docs for "script".

> Completely frustarted,
> Emilio

Regards

Klaus Major
[hidden email]
http://www.major-k.de

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

Re: stumped: set script of buttons at runtime

Klaus major-k
Hi Emilio,

> Hi Emilio,
>
>
>> Hi All,
>> I've been battling this problem for a few days and have no idea  
>> where to look next.  Originally I thought it had to do with global  
>> variable issues between stacks.  However, after MUCH hair-pulling  
>> it appears the problem has to do with setting the script property  
>> of buttons dynamically ...or so I think...Keep in mind the  
>> following code works ...
>> ...
>> and hence none of them work.  If I set the visibility of the  
>> original hidden button to true, it works fine.  So for some  
>> reason, setting the script of a button at runtime does not seem  
>> possible.  Does anyone know what I'm doing wrong here??
>>
>
> you are doing nothing wrong actually!
> You just have been hit by the "Scriptlimits", sorry :-/
>
> See the "Note" in the docs for "script".
>
>
>> Completely frustarted,
>> Emilio

after reading your mail a second time, i am not sure, if i understood  
your problem correctly :-/
Maybe not...?

How many statements/lines does the script have that you set dynamically?


Regards

Klaus Major
[hidden email]
http://www.major-k.de

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

Re: stumped: set script of buttons at runtime

Rob Cozens
In reply to this post by Eric Chatonet
Hi Eric,

>So for some
>reason, setting the script of a button at runtime does not seem
>possible.  Does anyone know what I'm doing wrong here??

Runtime changes to scripts by standalones are subject to the 10-line
restriction the applies to the do command.

If you are not building the new script based on runtime info, you could
have a hidden template button containing the new script, change the other
properties of the template button, and replace the old button with a copy
of the template.

Rob Cozens CCW
Serendipity Software Company

"And I, which was two fooles, do so grow three;
  Who are a little wise, the best fooles bee."

  from "The Triple Foole" by John Donne (1572-1631)

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

Re: stumped: set script of buttons at runtime

Sarah Reichelt
In reply to this post by Emilio Gagliardi
> I've been battling this problem for a few days and have no idea  
> where to look next.  Originally I thought it had to do with global  
> variable issues between stacks.  However, after MUCH hair-pulling  
> it appears the problem has to do with setting the script property  
> of buttons dynamically ...or so I think...Keep in mind the  
> following code works perfectly in development. That is, the last  
> line of the mouseUp handler in the hidden defaultButton says  
> "answer the script of me".  In development, after all the buttons  
> have been created, clicking any of the buttons generates a dialog  
> box and the appropriate script.  In standalone mode, the script of  
> all the dynamically created buttons is empty...even the "answer"  
> command on the last line on makeButtons returns empty

If your template script is more than 10 lines, it will work in the  
IDE, but not in a standalone as you are limited in creating new  
scripts there. However if you have multiple buttons all with the same  
script, then it would be easier to place the script higher in the  
message path and have them all use the same script.

There are 2 ways you could do this:

set the script of each button to:
   on mouseUp
     doMyButtonhandler
   end mouseUp
and have all the scripts in the "doMyButtonHandler" handler in the  
card or stack script.

Alternatively, just have a mouseUp script in the card or stack script  
containing all your button script and check "the target" each time it  
is called to see whether it is one of the buttons that should use the  
handler.

HTH,
Sarah

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

Scripts limits in stand alones (was: Re: stumped: set script of buttons at runtime)

Eric Chatonet
In reply to this post by Emilio Gagliardi
Hi all,

Obviouly I missed the subject: apoplogizes to you, Emilio :-)

Reminder from the docs:
When using a standalone application, an object's script property may  
not be set to a string containing more than ten statements. This  
limit is set by line 1 of the scriptLimits function. (This does not  
limit scripts that are already written: standalone applications can  
run scripts of any length. However, if the standalone attempts to  
change an object's script property, and the script contains more than  
the allowable number of statements, the attempt to set the script  
causes an error.)

I consider that, even there are many possible workarounds, this  
"feature" stays rather unacceptable:
Does an enterprise licence ($900) has to work as a DreamCard  
evaluation version?

Best Regards from Paris,

Eric Chatonet.
----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        [hidden email]/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------

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

Re: Scripts limits in stand alones

Richard Gaskin
Eric Chatonet wrote:

> Reminder from the docs:
> When using a standalone application, an object's script property may  
> not be set to a string containing more than ten statements. This  limit
> is set by line 1 of the scriptLimits function. (This does not  limit
> scripts that are already written: standalone applications can  run
> scripts of any length. However, if the standalone attempts to  change an
> object's script property, and the script contains more than  the
> allowable number of statements, the attempt to set the script  causes an
> error.)
>
> I consider that, even there are many possible workarounds, this  
> "feature" stays rather unacceptable:
> Does an enterprise licence ($900) has to work as a DreamCard  evaluation
> version?

The scriptLimits property was put in by Scott Raney long before RunRev
acquired it. It was added to prevent the ease with which someone could
create a competing scripting product (I've seen this before with other
xTalks).

It may seem onerous at first, but as was the case with the poster who
started this thread it's truly very rare that there is a need for
self-modifying Transcript.  Used well, the message path usually provides
a more efficient form of what's desired.

In the rare cases when there may some benefit from self-modifying code,
it often turns out that the more traditional "genetic algorithm"
approach of abstractifying behaviors through data often serves that
small subset well.

And in the rarer case where one truly needs to use self-modifying
Transcript, my understanding is that Kevin's willing to review things on
a case-by-case basis to see what can be done.

--
  Richard Gaskin
  Fourth World Media Corporation
  __________________________________________________
  Rev tools and more: http://www.fourthworld.com/rev
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Scripts limits in stand alones

Eric Chatonet
Hi Richard,

First, congratulations on RevJournal :-)
It becomes again a key site for all Rev developers.
BTW as I was in touch with Alan Beatie, I suggested him to update the  
RevJournal mention on the Runrev website (http://support.runrev.com/ 
resources/useful_sites.php)

Second, I am a kind man ;-)
I did not think of competing scripting products... made with Rev!
Tha'ts a good reason enough since there are many other ways to solve  
the issue.
My approach was more ethical than pragmatic...

Best Regards from Paris,

Eric Chatonet.

Le 17 juin 05 à 09:48, Richard Gaskin a écrit :

> Eric Chatonet wrote:
>
>> Reminder from the docs:
>> When using a standalone application, an object's script property  
>> may  not be set to a string containing more than ten statements.  
>> This  limit is set by line 1 of the scriptLimits function. (This  
>> does not  limit scripts that are already written: standalone  
>> applications can  run scripts of any length. However, if the  
>> standalone attempts to  change an object's script property, and  
>> the script contains more than  the allowable number of statements,  
>> the attempt to set the script  causes an error.)
>> I consider that, even there are many possible workarounds, this  
>> "feature" stays rather unacceptable:
>> Does an enterprise licence ($900) has to work as a DreamCard  
>> evaluation version?
>>
>
> The scriptLimits property was put in by Scott Raney long before  
> RunRev acquired it. It was added to prevent the ease with which  
> someone could create a competing scripting product (I've seen this  
> before with other xTalks).
>
> It may seem onerous at first, but as was the case with the poster  
> who started this thread it's truly very rare that there is a need  
> for self-modifying Transcript.  Used well, the message path usually  
> provides a more efficient form of what's desired.
>
> In the rare cases when there may some benefit from self-modifying  
> code, it often turns out that the more traditional "genetic  
> algorithm" approach of abstractifying behaviors through data often  
> serves that small subset well.
>
> And in the rarer case where one truly needs to use self-modifying  
> Transcript, my understanding is that Kevin's willing to review  
> things on a case-by-case basis to see what can be done.

----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        [hidden email]/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------

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