Page 1 of 1
Condensing/recognized script shorthand for "set" c
Posted: Wed Dec 31, 2008 2:40 pm
by gyroscope
(edit: title should be: ......for "set" code)
I've often wondered this, practically ever since I started using Rev (about 9 months ago):
If only a script similar to this
Code: Select all
set the visible of image "BLUE BACK" to false
set the visible of image "Wiper" to false
set the visible of button "Add" to false
set the visible of button "CheckB" to false
could be:
Code: Select all
set the visible of image "BLUE BACK" and image "Wiper" and button "Add" and button "CheckB" to false
This causes an error although I wonder if there is a similar condensed version which
does work? For readability, had this worked, it could have been:
Code: Select all
set the visible of\
image "BLUE BACK" and\
image "Wiper" and\
button "Add" and\
button "CheckB"\
to false
Also, if only
Code: Select all
set the visible of image "BLUE BACK" to false
set the enabled of image "BLUE BACK" to false
set the highlight of image "BLUE BACK" to false
could be:
Code: Select all
set the visible and the enabled and the highlight of image "BLUE BACK" to false
or better still:
Code: Select all
set the (visible and enabled and highlight) of image "BLUE BACK" to false
Would anyone else find this useful/easier? (It'd certainly be quicker...)
And is there already proper shorthand versions of the above, can anyone tell me please

Posted: Sun Jan 04, 2009 7:26 pm
by hamlynart
Couldn't agree with you more - I've often wondered the same myself.
Yesterday I also wished there was an alternative this:
Code: Select all
If the fld "betweenStates" >= 5 and the fld "betweenStates" <= 10
could be this:
Code: Select all
If the fld "betweenStates" is >=5 and <= 10
or better still:
Code: Select all
If the fld "betweenStates" is between 5 and 10
and while I'm on the subject what about:
Code: Select all
If fld "extremities" is <= 5 or >= 10
instead of:
Code: Select all
if fld "extremities" <= 5 or fld "extremities" >=10
We can but hope!
Jim H
Posted: Sun Jan 04, 2009 8:25 pm
by Mark
gyroscope,
Code: Select all
put "img 'Some Image 1'" & cr & "img 'Some Image 2'" & cr & \
"btn 'Some Button 1'" & cr & "btn 'Some Button 2'" into myList
replace "'" with quote in myList
repeat for each line myObject in myList
set the visible of myObject to true
end repeat
This is only one of very many way to shorten your code. Another way might be, in some cases:
Code: Select all
set the visible of grp "Some fields and some buttons" to true
or even shorter:
Code: Select all
show grp "Some fields and some buttons"
Be creative and you'll find a solution.
Hamlynart,
Code: Select all
put fld "Some Value" into V
if V >= 5 and V <= 10 and V >= 15 and V <=20 then
-- do someting here
end if
I very rarely do this, because I prefer to use meaningful variable names, but if you have a really very long if statement, you might add a comment to document the meaning of V and use V (or any other letter except A) instead of the field reference.
I don't use A, because A is a keyword. That's merely a matter of taste and style, though.
Best,
Mark
Posted: Mon Jan 05, 2009 12:35 am
by gyroscope
Thank you Mark, for your neat solutions. The only thing I would say about showing a group is that perhaps I might want to hide an individual one sometimes, so that I'd have to ungroup, then regroup again without the individual one, etc...if you get what I mean.
Still, useful to know.
Be creative and you'll find a solution.
I do try!

Posted: Mon Jan 05, 2009 12:46 pm
by bn
hi gyroscope,
I suppose you want the shortcut for repeatedly turning on and off a number of controls. You might consider putting this into a command like
Code: Select all
on showHide ptrue
set the visible of field 1 to ptrue
set the visible of btn 1 to ptrue
set the visible of field 2 to not ptrue
set the visible of button 2 to not ptrue
-- and so on
end showHide
and call this depending on your needs like this
Code: Select all
on mouseUp pMouseBtnNo
-- some code here
-- condition here
showHide true
--else
showHide false
-- end condition
-- rest of code
end mouseUp
If you put the command showHide into the card script or the stack script you can call it from different places. It saves a lot of scripting especially if you want to add controls to be shown / hidden later on. I use this stuff for example in a tabbed control on a substack with just one card and 3 tabs. Just turning on and off fields etc wholesale depending on the tab.
As Mark said, there many ways to do this.
cheers
bernd
Posted: Mon Jan 05, 2009 1:19 pm
by Mark Smith
Code: Select all
If the fld "betweenStates" >= 5 and the fld "betweenStates" <= 10
What I tend to do in these cases is
Code: Select all
get fld "betweenStates"
if it >=5 and it <= 10 then....
I find this use of the 'it' variable helps me to keep things readable and clear.
Posted: Mon Jan 05, 2009 1:39 pm
by Mark
Hi Mark,
I avoid using the it variable as much as possible, because it can easily cause unexpected errors. Too often, I wrote scripts that used the it variable, entered a small piece of code that included an answer or it command, and discovered I had to adjust my entire script.
Best,
Mark
Posted: Tue Jan 06, 2009 12:43 am
by gyroscope
Jim:
We can but hope!
Hope springs eternal, as they say!
That's a neat way to show and hide stuff Bernd, thank you.
