April 30, 2024, 07:54:10 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Expression Eval by Joske

Started by aurelCB, April 14, 2010, 01:34:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

April 14, 2010, 01:34:43 PM Last Edit: March 04, 2023, 02:46:17 AM by aurelCB
...


GWS

April 15, 2010, 02:16:48 AM #1 Last Edit: April 15, 2010, 03:25:18 AM by GWS
Hi Aurel,

Nice try ..  :)  Joske is a really clever programmer.

If you try the expression 2 * sqrt(7), you will uncover a couple of errors.

Near line 340, you will find bc++ and bo++ which need to be changed to bc = bc + 1, and bo = bo + 1.
(In good old Basic fashion ..  :))

Also, it needs a function declaration at the start of the program ..
DECLARE eval_function(name as STRING, expr as STRING)

That gets the program to run and it gives the correct answer - but the output formatting also needs to be changed.
Embedded control characters like '\t' don't work in CB.  It would require chr$(9) for a Tab or chr$(10) for a new line.

Near line 130 this helps format the output ..
result = chr$(10) + expression + chr$(9) + eval_line(expression)

A nice program to play with though ..

best wishes, :)

Graham
Tomorrow may be too late ..