FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM

TEXT
Parse text for mathematical functions
Basically you're going to have to make a function and "parse" it out. Just a basic expression parser is below. It'll take two simple numbers and evaluate them, for example, 2*2 or 36 or 4/4444, even hex numbers like &Hff/&Hf, and a combination like 17*&Hf.
What you'll need to do is break down the math into simpler terms, for example:
(5*4)8
Turn it into 5*4
and then into
208
Then you add variables, x,y,z, etc.
The key to doing it is breaking it into simpler parts, and recursing the input line until your line is blank. And then somehow you have to be able to handle errors too.
Keep in mind below is just a simple one that'll take two numbers and one math type(,+,*,/)
Here it is:
COMPILE 0,_caseInsensitive
END GLOBALS
WINDOW #1,,(0,0)(320,200)
INPUT "Enter your expression: ";aa$
multis% = INSTR(1,aa$,"*")
divis% = INSTR(1,aa$,"/")
addis% = INSTR(1,aa$,"+")
subis% = INSTR(1,aa$,"")
relation% = 1
IF multis% THEN relation% = multis%:rtype% = 1
IF divis% THEN relation% = divis%:rtype% = 2
IF addis% THEN relation% = addis%:rtype% = 3
IF subis% THEN relation% = subis%:rtype% = 4
LONG IF relation% <> 1
leftexp$ = LEFT$(aa$,relation%  1)
rightexp$ = MID$(aa$,relation% + 1)
lexp& = VAL(leftexp$)
rexp& = VAL(rightexp$)
SELECT CASE rtype%
CASE 1
ans# = lexp&*rexp&
CASE 2
ans# = lexp&/rexp&
CASE 3
ans# = lexp&+rexp&
CASE 4
ans# = lexp&rexp&
END SELECT
PRINT "Answer: ";ans#
XELSE
PRINT "Work with me here people..."
END IF
DO
UNTIL FN BUTTON
