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.

DarkBASIC Professional Discussion / Something I would love to see added to DBPro

Author
Message
Galiem
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location: United States
Posted: 4th Apr 2003 01:50
I can't remember where I saw this, so if anyone can refresh my memory, I would greatly appreciate it.

It's tough to explain how this works in a way. The thing I'm talking about is actually a mathematical operator, which is useful in certain types of calculations. To explain, I'll give an example. Basically, it's a "If variable = 10 give or take 5" type operator.

Let's say you wanted to specify a certain area on the screen as a "zone" for the cursor. What I mean is, if the cursor is in this area, something happens. A way you could do it is:



That's a mouthful! Alot for the compiler to do!

The operator I'm talking about works like this:

You use a tilda (spelling?) sign in place of the equals sign. You next enter the value wanted, then in parenthesis, the range upon which to calculate. So, the above example would be



Or, If mx is approximately 2, give or take one, and my is approximately 2, give or take one, then the statement is true.

Anyway, would LOVE to see this in DBPro (or just remember where the heck I saw it before lol bothers ya when you can't remember something)
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 4th Apr 2003 02:56 Edited at: 4th Apr 2003 02:56
Thats a good idea. I made a small function for that:



Where value is the number to test, valueb is what it is equal to, and tolerance is how much to give or take.

Example:



It would still be nice to have a built-in "~" Symbol though.

All programmers are playwrights and all computers are lousy actors." -Anon.
<--- Ouch, my head!
Glennyboy
23
Years of Service
User Offline
Joined: 26th Feb 2003
Location: United Kingdom
Posted: 4th Apr 2003 14:22
Wouldn't this be easier? (And allow for decimals)



Shadow
23
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 4th Apr 2003 16:03
Yes. I was going to point that out, but you beat me to it.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 4th Apr 2003 16:05 Edited at: 4th Apr 2003 16:06
hehe - right idea Glenny, but you are testing the value against itself!



Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.
Galiem
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location: United States
Posted: 5th Apr 2003 01:16
Still alot for the compiler to do 8)

Not bad 8) I was trying to think of a way to do that with a FOR / NEXT type statement, but it kept escaping me

Most situations run faster and are better suited for an IF statement though

However, if we had use of the ~ symbol, the difference in running and compile speed would be significant enough that one wouldn't have to run through mini loops, such as FOR NEXT (I try to avoid those, as it kinda keeps the program from doing other things until it's finished)

Maybe when I learn a bit more, I'll be able to come up will a DLL that adds the operator, but right now, I don't think it's possible to define an operator using a DLL, unfortunately.

Actually, if it can be done, and anyone knows a little spot on the web about it or about how, then I can get started on that ASAP 8) Would be worth it to pause my own program to make that tool 8)

andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 5th Apr 2003 02:40
Hmm.. Wonder why I never thought of that?

All programmers are playwrights and all computers are lousy actors." -Anon.
<--- Uh... Um... Oh I forgot

Login to post a reply

Server time is: 2026-07-10 17:17:52
Your offset time is: 2026-07-10 17:17:52