Page 1 of 1

<,> and how to use both

Posted: Wed Feb 13, 2008 10:47 am
by bjb007
I want to check that a number is greater than 10 and
less than 20.

Seems I can't use something like

If myArray[1] >10 and <20

or any variations I can think of.

Can't find anything like 'instring' apart from
'contains' which I don't think will work with numbers...

Posted: Wed Feb 13, 2008 11:05 am
by Klaus
Hi bjb007,

Rev can only check one condition at a time so you have to:
...
if myArray[1] >10 AND myArray[1] <20 then
...


Best

Klaus

Greater than ...

Posted: Wed Feb 13, 2008 11:31 am
by bjb007
Oh hell, not another one.

Rev seems to specialize in unnecessarily long
and convoluted ways of doing things.

Perhaps we could go back to the old "dot"
notation of dBase c. 1990...

If --- .and. ----.

If only Rev had a #define function.....

If only.....

Posted: Wed Feb 13, 2008 11:45 am
by Klaus
Well, a small thank you would actally have been enough for me ;-)

Thank you...

Posted: Wed Feb 13, 2008 12:40 pm
by bjb007
Klaus

Apologies and thank you.

I was rather annoyed at the time....

Now I'm trying to figure out how to increment the
contents of an array element. Has, say 1 in it
and I want to add 1.

Sure I've seen it somewhere but can't find it.

Posted: Wed Feb 13, 2008 12:42 pm
by Klaus
:-)

...
add 1 to your_array[tKey]
...

Thanks

Posted: Wed Feb 13, 2008 12:53 pm
by bjb007
Thanks Klaus.

Posted: Wed Feb 13, 2008 2:58 pm
by malte
Just 2 euro cents:

I avoid dot syntax as the devil would holy water...

I like the wordy variants :) Not too many dots for me please.

All the best,

Malte

Re: Greater than ...

Posted: Thu Feb 14, 2008 12:07 am
by Mark Smith
bjb007 wrote: Rev seems to specialize in unnecessarily long
and convoluted ways of doing things.
xTalks tend to be a bit verbose at times, but you have to remember the times when a one-liner can achieve what would take many lines of code in some other languages.

In this case, if 'between' is a common requirement, you can easily factor it out to a function:

Code: Select all

function isBetween pNum, pUpperLimit, pLowerLimit
  return pNum > pLowerLimit AND pNum < pUpperLimit
end isBetween
so then you can use

if isBetween(myArray[1], 10, 20) then....

Best,

Mark