Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How to write "does not equal"

Author
Message
Butter fingers
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 18th Oct 2007 19:49
OK, so, call me a retard. I don't care.

In my current code, enemies are given factions through a string array
ie
Entity_faction$(x)="yardies"

say I have 10 factions , and I want an entity to know when he's not near another entity of his faction...

how do I say "doesn't equal"

as in

if Entity_faction$(x)=Entity_faction$(y)
will find if entities x and y are in the same faction. what do I use instead of a "=" to find if they are not in the same faction?
I don't want to use and "else", because...well, because I tried it and it doesn't work!

pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Oct 2007 20:32
Quote: "I don't want to use and "else", because...well, because I tried it and it doesn't work!"


It is strange.
Will you show a cord?
Veron
17
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 19th Oct 2007 12:41
I always thought "does not equal" was expressed like this: !=


Butter fingers
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 20th Oct 2007 02:59
Thanks. Does <> work for string as well as numeric values? I have used it elsewhere but assumed it meant "is greater or less than" and wouldn't work with a string.

Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 20th Oct 2007 03:02
You could always use not but I think I heard it has some bugs, what I usually do is make an if else endif statement for does not equal type statements probably not the best way to do it though.

HeavyAmp
17
Years of Service
User Offline
Joined: 25th Oct 2006
Location: Castle in the Sky!
Posted: 20th Oct 2007 07:12
Yeah it seems to work with Strings



Better to be dead, than to live your life afraid.
Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 20th Oct 2007 21:27
thanks! omg my code is now 23ms faster ^^

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Oct 2007 10:59 Edited at: 21st Oct 2007 11:00
Quote: "I have used it elsewhere but assumed it meant "is greater or less than""


It does!

If you have the number 10, then any other number which is less than 10 or greater than 10 doesn't equal 10.

It's just referred to as 'not equal to' because when dealing with strings it doesn't make sense to talk about 'less than' or 'greater than' another string.

TDK_Man

calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 21st Oct 2007 13:28
Well if something is not equal it's got to be either greater than or less than!

Your signature has been erased by a hyper-intelligent pan-dimensional being (a mod)
Seannydog
16
Years of Service
User Offline
Joined: 23rd Oct 2007
Location:
Posted: 24th Oct 2007 14:42
slightly obvious that one clacyman

Nothings impossible
These forum signatures are meant to hold 200 characters. 200 characters my as
Vidiot
18
Years of Service
User Offline
Joined: 15th May 2006
Location: TN
Posted: 26th Oct 2007 16:49
Actually, being able to use greater or less than when trying to compare and sort text strings alphabetically would be a useful thing. "Aaron" would be less than "Apple" alphabetically. I know you can do it with CHR$() but that would only work one charactor at a time.

The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.
Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 27th Oct 2007 13:56
In fact it is "greater or less than". You can also compare strings this way in DBP, so I don't know where the problem is.



David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 27th Oct 2007 19:06 Edited at: 27th Oct 2007 19:08
Quote: "So how is "abc" greater or less than "yzx"? Again, "greater or less than" applies to algebra, not to a progarmming language when comparing strings. A strings is either equal to another or not.
"


Remember, strings are effectively a sequence of numbers - each character is represented by an individual number (an ASCII code presumably in this case)

So if each character in one string is <> (not equal to) the character in the other string, then they're not equal


09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Oct 2007 03:44
Yup - He has a point

"A" < "B" is true - Because ASCII code for "A" is less than "B"

"B" > "A" is true - Because ASCII code for "B" is greater than "A"

"A" <> "B" is true - Because "A" does fall in the "less or greater" than "B" criteria for a true evaluation.

"A" <> "A" is false - because "A" is NOT greater or Less than "A"

In Basic - that's how it works. NOW in C#, and C++ - the "!=" literally stands for NOT EQUAL. One could argue its the same thing - and you're not wrong - but neither is calling it what is is "Greater than or less than"

YOU ARE ALL CORRECT

Login to post a reply

Server time is: 2024-09-27 08:23:03
Your offset time is: 2024-09-27 08:23:03