My program is a pseudo database. There is a splash screen stack and a one card user interface stack. Then there are numerous stacks holding images and data for each separate topic.
When a user selects a menu item on the UI, a handler generates scripts for each of the buttons on the UI card and goes off to the appropriate data stack to find the correct images and text. This works fine in Revolution.
However when I create an application, the scripts on the UI are not updated by menu selection but appear to be the scripts last used before the application was created.
What is going on?
Interactive scripting of buttons not working in application
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Hi peramangk,
you are pretty much likely hitting the script limits. In a standalone application setting the scripts of an object i limited to 10 statements per script.
From the dictionary:
all the best,
Malte
you are pretty much likely hitting the script limits. In a standalone application setting the scripts of an object i limited to 10 statements per script.
From the dictionary:
However there are other ways than dynamic scripting to reach yor goal I am sure. If you posted a code snippet I am sure we can help you reach your goal.You can view and change a script directly by selecting the object and choosing Object menu Object Script. Use the script property within a handler to check the contents of a script, or change the script.
Note: 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.)
all the best,
Malte
Thanks Malte for your quick reply.
It raises two points.
Firstly, can I cheat a little by creating another handler with 10+ lines and then just call that handler as one line of code in the dynamic script for the buttons?
Secondly, it seems like a weird limit to have. Why is it so small? The documentation suggests it is not an absolute limit. Is there any way of altering it?
Here is the script I was using. It writes a script for n number of thumbnail pictures on the UI card.
I'm certainly interested in alternative strategies.
on createThumbnailScript xxxxxName,thumbnailName,thumbnailPlaceNumber,photoName
-- gcp 070916
-- This handler is called by the handler publishxxxxx
-- Its purpose is to create a script for each thumbnail picture on displayCard.
-- Each script has to -
-- 1. control the comments, month and site notes
-- 2. show the appropriate main photo
-- 3. call the visual effect
-- 4. set the cursor to hand on mouseEnter
-- 5. set the cursor to arrow on mouseLeave
local thumbNailScriptTemp
put "on mouseUp" & return & \
"lock screen" & return & \
"set the visible of field" && quote & "textDisplay" & quote && "to false" & return & \
"put image" && quote & photoName & quote && "of card 1 of stack" && quote & xxxxxName & quote &&\
"into image" && quote & "xxxxxImage" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return &\
"put the comments of image" && quote & thumbnailName & quote && "of card 1 of stack" &&\
quote & xxxxxName & quote && "into field" &&\
quote & "comments" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return & \
"put the month of image" && quote & thumbnailName & quote && "of card 1 of stack" &&\
quote & xxxxxName & quote && "into field" &&\
quote & "month" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return & \
"put the site of image" && quote & thumbnailName & quote && "of card 1 of stack" &&\
quote & xxxxxName & quote && "into field" &&\
quote & "site" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return & \
"go card" && quote & "displayCard" & quote && "of stack" && quote & "mainStack" & quote & return &\
"doVisualEffect" & return & "unlock screen" & return & \
"end mouseUp" & return & return &\
"on mouseEnter" & return & \
"set the borderWidth of me to" && quote & "3" & quote & return & \
"lock cursor" & return & \
"set the cursor to hand" & return & \
"end mouseEnter" & return & return &\
"on mouseLeave" & return & \
"set the borderWidth of me to" && quote & "1" & quote & return & \
"set the cursor to arrow" & return & \
"unlock cursor" & return & \
"end mouseLeave" & return\
into thumbnailScriptTemp
set the script of image thumbnailPlaceNumber of card "displayCard" of stack "mainStack" to thumbNailScriptTemp
end createThumbnailScript
It raises two points.
Firstly, can I cheat a little by creating another handler with 10+ lines and then just call that handler as one line of code in the dynamic script for the buttons?
Secondly, it seems like a weird limit to have. Why is it so small? The documentation suggests it is not an absolute limit. Is there any way of altering it?
Here is the script I was using. It writes a script for n number of thumbnail pictures on the UI card.
I'm certainly interested in alternative strategies.
on createThumbnailScript xxxxxName,thumbnailName,thumbnailPlaceNumber,photoName
-- gcp 070916
-- This handler is called by the handler publishxxxxx
-- Its purpose is to create a script for each thumbnail picture on displayCard.
-- Each script has to -
-- 1. control the comments, month and site notes
-- 2. show the appropriate main photo
-- 3. call the visual effect
-- 4. set the cursor to hand on mouseEnter
-- 5. set the cursor to arrow on mouseLeave
local thumbNailScriptTemp
put "on mouseUp" & return & \
"lock screen" & return & \
"set the visible of field" && quote & "textDisplay" & quote && "to false" & return & \
"put image" && quote & photoName & quote && "of card 1 of stack" && quote & xxxxxName & quote &&\
"into image" && quote & "xxxxxImage" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return &\
"put the comments of image" && quote & thumbnailName & quote && "of card 1 of stack" &&\
quote & xxxxxName & quote && "into field" &&\
quote & "comments" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return & \
"put the month of image" && quote & thumbnailName & quote && "of card 1 of stack" &&\
quote & xxxxxName & quote && "into field" &&\
quote & "month" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return & \
"put the site of image" && quote & thumbnailName & quote && "of card 1 of stack" &&\
quote & xxxxxName & quote && "into field" &&\
quote & "site" & quote && "of card" && quote & "displayCard" & quote &&\
"of stack" && quote & "mainStack" & quote & return & \
"go card" && quote & "displayCard" & quote && "of stack" && quote & "mainStack" & quote & return &\
"doVisualEffect" & return & "unlock screen" & return & \
"end mouseUp" & return & return &\
"on mouseEnter" & return & \
"set the borderWidth of me to" && quote & "3" & quote & return & \
"lock cursor" & return & \
"set the cursor to hand" & return & \
"end mouseEnter" & return & return &\
"on mouseLeave" & return & \
"set the borderWidth of me to" && quote & "1" & quote & return & \
"set the cursor to arrow" & return & \
"unlock cursor" & return & \
"end mouseLeave" & return\
into thumbnailScriptTemp
set the script of image thumbnailPlaceNumber of card "displayCard" of stack "mainStack" to thumbNailScriptTemp
end createThumbnailScript
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
the script limit of setting scripts during runtime in standalones is 10. however this is in respect to each object in turn. so you could set the script of an object to 9 lines, then another object to 10 lines, and add a line that executes the script of the other object.
In addition to the usual message path traversing, you can "send" or "call" commands to/from other objects. Also, with the use of all frontscripts, backscripts and stacksinuse, you could have almost thousands of script lines, without ever needing to use "send".
Finally there's "do" which again allows you to execute 10 lines, but "do" is known to be slower then native scripts.
There used to be a version of rev that is free, but only allowed you to test it within the script limits. Nonetheless (and thanks to the included explanation about how to use all available methodes) I was able to make pretty complex stuff with it.
In addition to the usual message path traversing, you can "send" or "call" commands to/from other objects. Also, with the use of all frontscripts, backscripts and stacksinuse, you could have almost thousands of script lines, without ever needing to use "send".
Finally there's "do" which again allows you to execute 10 lines, but "do" is known to be slower then native scripts.
There used to be a version of rev that is free, but only allowed you to test it within the script limits. Nonetheless (and thanks to the included explanation about how to use all available methodes) I was able to make pretty complex stuff with it.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Hi peramangk,
You are using a very difficult and complicated strategy, while what you want to do is very simple.
Suppose that you have many image objects and that you want to drag an image if you click on it and hold the the mouse (I will make a quick-and-dirty example):
Note that I use "the target" instead of "me". Now, put this script at card level and each image on your card can be dragged. There is no need whatsoever to set the script of any object.
With this knowledge, you can rewrite your script, replacing "me" with "the target" and possible making a few more small adjustments. Also, you will avoid a lot of fiddling with scripts, because you need only one set of scripts at card level.
Best,
Mark
You are using a very difficult and complicated strategy, while what you want to do is very simple.
Suppose that you have many image objects and that you want to drag an image if you click on it and hold the the mouse (I will make a quick-and-dirty example):
Code: Select all
on mouseDown
repeat until the mouse is up with messages
set the loc of the target to the mouseLoc
wait 0 millisecs with messges
end repeat
end mouseDown
With this knowledge, you can rewrite your script, replacing "me" with "the target" and possible making a few more small adjustments. Also, you will avoid a lot of fiddling with scripts, because you need only one set of scripts at card level.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode