Questions to help with my first app
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Questions to help with my first app
I have been working with Revolution for 4 days now, and my only complaint is how the documentation is laid out. (more to be read cover to cover then as a reference) I admit I have not yet read all 400 pages, but I have searched them for answers with little results. Here are a couple things I need to know.
How can I dynamically change the choices in an option menu to match values in an array?
Is there any place to write scripts that are not tied to an object but are globally callable from within object scripts. I have some rather long scripts that need to be called from within nested if statements, and I would rather not place the entire scripts in each object if possible.
sorry if these questions are a bit noobish, I'm just not used to this program yet.
How can I dynamically change the choices in an option menu to match values in an array?
Is there any place to write scripts that are not tied to an object but are globally callable from within object scripts. I have some rather long scripts that need to be called from within nested if statements, and I would rather not place the entire scripts in each object if possible.
sorry if these questions are a bit noobish, I'm just not used to this program yet.
Hi magice, I think I can help with your second question, if I understand you correctly: if you mean exactly the same script but called up from multiple objects you can use a custom handler.
So you decide on the name of your handler and this can be placed anywhere, even in the stack script (probably the best place).
A simple example would be, for a button, lets say:
Then in the stack script:
It's best to write your custom handler first so that the engine recognises it so you can call it from another object script.
Hope that's helpful for you.

So you decide on the name of your handler and this can be placed anywhere, even in the stack script (probably the best place).
A simple example would be, for a button, lets say:
Code: Select all
on mouseUp
---do the stuff specific to this button only
---
---
---
myHandler
---
---
end mouseUp
Code: Select all
on myHandler
---do the stuff thats
--generic to all your objects
end myHandler
Hope that's helpful for you.

Hi magice,
You might also be interested to learn about developments coming up in the forthcoming 3.5 release, like those introduced here http://www.runrev.com/newsletter/februa ... etter2.php and here http://www.runrev.com/newsletter/march/ ... N067S36053 which cover the concept of "behaviors" - where code can be reused in many controls - akin to an "include" file in other environments.
As to the dynamic changing of option menu choices, it's as simple as setting the text of the button. If you have an array with the choices, you may need to convert that (cf 'combine') beforehand, but just
HTH
You might also be interested to learn about developments coming up in the forthcoming 3.5 release, like those introduced here http://www.runrev.com/newsletter/februa ... etter2.php and here http://www.runrev.com/newsletter/march/ ... N067S36053 which cover the concept of "behaviors" - where code can be reused in many controls - akin to an "include" file in other environments.
As to the dynamic changing of option menu choices, it's as simple as setting the text of the button. If you have an array with the choices, you may need to convert that (cf 'combine') beforehand, but just
Code: Select all
set the text of button "myOptionMenu" to <<theSingleColumnCRdelimitedList>>
thanks SparkOut I think you have me almost there. I Dumped my array into a new temporary array and combined it using comma. the code looks like this
on populateTarget
global tArray
global tTargetArray
put tArray[2] into tTargetArray
combine tTargetArray using comma
set the text of button "Target" to tTargetArray
end populateTarget
unfortunately when executed I get one single option in the drop down that is a comma delimited list of my array contents. What I am after is for each of those array values to become a separate option in the drop down.
Thanks, You have been a great help
on populateTarget
global tArray
global tTargetArray
put tArray[2] into tTargetArray
combine tTargetArray using comma
set the text of button "Target" to tTargetArray
end populateTarget
unfortunately when executed I get one single option in the drop down that is a comma delimited list of my array contents. What I am after is for each of those array values to become a separate option in the drop down.
Thanks, You have been a great help
You are correct. In the final script it will not be global. However I am temporarily making all of my variables global so that data will be held for debugging purposes. That way if I get unexpected results I can look at it and figure out what I did.
Now on to my next stumbling block.
I need to rearrange my array into numerical order by using the value of the first element of each line while keeping the sub elements of each line intact.
E.G.
array before sorting:
9 , lisa , redhead ,green eyes
5 ,sue , brunette, brown eyes
10 , kim , blonde, blue eyes
array after sorting:
10 , kim , blonde, blue eyes
9 , lisa , redhead ,green eyes
5 ,sue , brunette, brown eyes
(no this is not my array. It is just an example =p)
In C++ I would do this with a for loop using the iteration variable within the array name to specify which array values to compare. Then I would use an if statement within the loop to switch the two array values accordingly. I have played with the repeat command, but without an iteration variable it doesn't seem possible. I also stumbled onto the sort command which, if I am reading the syntax correctly (big if) would seem to be designed to do the process for me. However it does not seem to work. Am I on the right track or is there or is there something else I should be looking at? Again please forgive me for the noobishness of my questions and thanks for your help.
Now on to my next stumbling block.
I need to rearrange my array into numerical order by using the value of the first element of each line while keeping the sub elements of each line intact.
E.G.
array before sorting:
9 , lisa , redhead ,green eyes
5 ,sue , brunette, brown eyes
10 , kim , blonde, blue eyes
array after sorting:
10 , kim , blonde, blue eyes
9 , lisa , redhead ,green eyes
5 ,sue , brunette, brown eyes
(no this is not my array. It is just an example =p)
In C++ I would do this with a for loop using the iteration variable within the array name to specify which array values to compare. Then I would use an if statement within the loop to switch the two array values accordingly. I have played with the repeat command, but without an iteration variable it doesn't seem possible. I also stumbled onto the sort command which, if I am reading the syntax correctly (big if) would seem to be designed to do the process for me. However it does not seem to work. Am I on the right track or is there or is there something else I should be looking at? Again please forgive me for the noobishness of my questions and thanks for your help.
OK i figured out that the sort command doesn't work with arrays. I had to combine the arrays, do the sort, and then split them back.
Now I have another problem with my earlier created "dynamic drop down menu" Since the contents of the menu is unknown until data fields are filled out by the user, I have no way of knowing the user choices for creating a switch command. Is there any way to reference the item number of the choices as the case condition value instead of the actual choice text? Or, is there a way to use the value of a variable as the case condition value?
Now I have another problem with my earlier created "dynamic drop down menu" Since the contents of the menu is unknown until data fields are filled out by the user, I have no way of knowing the user choices for creating a switch command. Is there any way to reference the item number of the choices as the case condition value instead of the actual choice text? Or, is there a way to use the value of a variable as the case condition value?