Page 1 of 1

How to refer to an object and it's properties in a script?

Posted: Mon Dec 07, 2009 8:16 pm
by Top Gun
Hi everyone!

I searched through the topics on this forum, program documentation and the user guide but didn't manage to find the answer so decided to ask you for some help.

Here is that "monster" :) how in a script can I refer to an object on a stack if I know it's name but also it's name depends on a value of a variable? I.e. I want to have something like this

set visible of graphic "image" + image_number to true
So that if image_number is 34 then the object "image34" will be made visible.

Any ideas?

P.S. I guess there must be some function which can convert an integer digit into a string one. But also I need to merge two strings after that. Can't find any in the documentation, unfortunately.

Re: How to refer to an object and it's properties in a script?

Posted: Mon Dec 07, 2009 8:26 pm
by bn
Hi Top Gun,
welcome to the forum.
there is no need in Rev to declare a number as literal. For your case try something like this:

Code: Select all

on mouseUp
   set the visible of field ("f" & 1) to not the visible of field ("f" & 1)
end mouseUp
The same for a variable

Code: Select all

on mouseUp
   put 1 into i
   set the visible of field ("f" & i) to not the visible of field ("f" & i)
end mouseUp
you could use this in a repeat loop. This toggles the visible of field "f1", of course you can just set the visible to false, and it works on images as well. Just don't forget to put it in brackets.
regards
Bernd

Re: How to refer to an object and it's properties in a script?

Posted: Mon Dec 07, 2009 8:28 pm
by FourthWorld
If your script isn't working try button the part that concatenates the object name between parens to make sure the engine evaluates that first:

set visible of graphic ("image" + image_number) to true

Re: How to refer to an object and it's properties in a script?

Posted: Mon Dec 07, 2009 8:39 pm
by Top Gun
set visible of graphic ("image" & image_num) to true
Works fine!

Thank you, bn :)