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.

Program Announcements / DBPro expression evaluator plugin

Author
Message
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 25th Oct 2003 13:10
Not quite a plugin (I'm not a C++ type i'm afraid) but thois does the job just as well.

This will return the answer to any expression passed to it, eg:

(4+3*(7-9))^2

Syntax:

eval(exp$)

The ZIP includes demo source and exe.

http://www.davidtattersall.me.uk/db/downloads/DBProExpEval.zip

Fishie says:
"Those who fail to prepare prepare to fail"
"Rules are for the guidance of the wise and the blind obdeniency of the fools"
keeblerElf
21
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 27th Oct 2003 21:42
Oh why oh why oh why didn't this exist about 2 months ago
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 28th Oct 2003 06:55
Excellent, thank you !

--Mouse: Famous (Avatarless) Fighting Furball

A very nice %it, indeed.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Oct 2003 14:55
Hehe, been meaning to write one of those for years - nice one David, that's gonna be invaluable to a lot of DB'ers.


Van-B

David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 28th Oct 2003 16:48
Quote: "Oh why oh why oh why didn't this exist about 2 months ago "

Hehe it did, never got round to releasing it!

Quote: "Excellent, thank you !"


No problem

Quote: "Hehe, been meaning to write one of those for years - nice one David, that's gonna be invaluable to a lot of DB'ers."


Thanks, I got the idea when I saw how hard it was to evaluate a decent expression in DB

"The trouble with the French is that they have no word for 'entreprenuer'" - Pres. George W Bush
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 3rd Nov 2003 17:28
Is this not the same as Text?

text 10,10,str$((4+3*(7-9))^2)

wait key

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 3rd Nov 2003 22:48
Errr No.

If you have a program that builds expressions on the fly there is no way to evaluate them at present without this plugin.

So of you have built a string

s$="(4+3*(7-9))^2"

there is no native DB command to evaluate it, like other languages have.

Boo!
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 4th Nov 2003 09:45
Spook

text 10,10,str$((4+3*(7-9))^2)
wait key

prints "4"

what does this plugin calculate?

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 4th Nov 2003 12:17
It also calculates 4 but that is not the point!

DBPro will only evaluate values that are predetermined. What if program generates an expression from user input and builds a string, lets say expression$

There is no way to evaluate it without this plugin. Try it. Have line 1 as

s$="4+4"

Now try and use any of DBPro's commands to write out the result.

Boo!
TheOneRing
21
Years of Service
User Offline
Joined: 28th Aug 2003
Location: Right here.
Posted: 5th Nov 2003 17:00 Edited at: 5th Nov 2003 17:07
An interesting approach. I have tried (not too hard) to convert my expression parser I wrote in C++ to DBP. I have had difficulty, however, becuase mine relies on pointer variables, something DBP lacks good support for (at least I can't seem to get it to work right). Mine also evaluates user-defined functions as part of an expression (much like C++). What did you write it in?

Just curious...

Login to post a reply

Server time is: 2024-11-21 15:07:09
Your offset time is: 2024-11-21 15:07:09