<,> and how to use both

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

<,> and how to use both

Post by bjb007 » Wed Feb 13, 2008 10:47 am

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...

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Feb 13, 2008 11:05 am

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

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Greater than ...

Post by bjb007 » Wed Feb 13, 2008 11:31 am

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.....

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Feb 13, 2008 11:45 am

Well, a small thank you would actally have been enough for me ;-)

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Thank you...

Post by bjb007 » Wed Feb 13, 2008 12:40 pm

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.

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Feb 13, 2008 12:42 pm

:-)

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

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Thanks

Post by bjb007 » Wed Feb 13, 2008 12:53 pm

Thanks Klaus.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Wed Feb 13, 2008 2:58 pm

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

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Re: Greater than ...

Post by Mark Smith » Thu Feb 14, 2008 12:07 am

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

Post Reply