Page 1 of 1 1
Topic Options
#123964 - 2004-07-27 11:09 AM How to compare more than two vars?
GyroTwister Offline
Fresh Scripter

Registered: 2003-01-29
Posts: 15
Loc: Hoogeveen, The Netherlands
To all,

Maybe this message should be in KiXtart FAQ & How to's but let's give it a try.

The problem:
I've got 3 variables. If all the vars are the same, the content of the var is put in a 4th var.

If the 1st var is not equal to the 2nd one but the 2nd is equal to the 3rd. The 2nd var has te be put in the 4th var.

If none of the vars are equal the 1st var has te be put in the 4th var.

And so on and so forth....

With 3 vars I've 8 possible outcomes. How to do this in scripting.

I've been looking for select...endselect but I'm not certain whether is doing what I want.

Does anyone have an idea how to solve the problem?

Do I have to use an array? Can it be done with select...endselect?

t.i.a. Philip
_________________________
-------------------------------------------------------------- With kind regards, GyroTwister

Top
#123965 - 2004-07-27 11:42 AM Re: How to compare more than two vars?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hi P_style,

Looks like you live pretty close to where the board is hosted.

Well, I think these links here should help point you in the right direction.

Truth Tables, XOR-XNOR, BOOLEAN is the sort of item you need to do this.

XOR() - Exclusive OR operation using bitwise AND
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=82849

Bitwise operation help please
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB2&Number=108816

Bitwise Mathematical AND operation
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB1&Number=18222

Boolean functions
http://scitec.uwichill.edu.bb/cmp/online/P10F/rulesof.htm

Top
#123966 - 2004-07-27 02:00 PM Re: How to compare more than two vars?
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
In my opinion there are only five possibilities.

It can be done by select...case...endselect.

This should do it:
Code:
Select

Case $a<> $b AND $b <> $c AND $c <> $a
?"no vars are the same"
;
Case $a = $b AND $b = $c AND $c = $a
?"all vars are the same"
;
Case $a = $b AND $b <> $c AND $c <> $a
?"a and b are the same"
;
Case $a <> $b AND $b = $c AND $c <> $a
?"b and c are the same"
;
Case $a <> $b AND $b <> $c AND $c = $a
?"a and c are the same"
EndSelect



Little explanation:
First I came up with eight possibilities too but there are three examples that can never bee true like when

Code:

$a <> $b and $b = $c and $c = $a



This one can never bee true because a is not equal to b, b is equal to c and c should be equal to a. If this is true the a should be equal to b witch is it not. So only five possibilities according to me.

[edit]
5 possibilities
[/edit]


Edited by R2D2 (2004-07-27 02:07 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#123967 - 2004-07-27 04:12 PM Re: How to compare more than two vars?
GyroTwister Offline
Fresh Scripter

Registered: 2003-01-29
Posts: 15
Loc: Hoogeveen, The Netherlands
Thank you all for the swift replies.

I'm currently scripting it and the first test looks promosing.

Again thanks for all the contributors.

_________________________
-------------------------------------------------------------- With kind regards, GyroTwister

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.204 seconds in which 0.156 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org