# formula solver 2/7

``` BBS: Inland Empire Archive
Date: 03-13-93 (22:24)             Number: 335
From: QUINN TYLER JACKSON          Refer#: NONE
To: ALL                           Recvd: NO
Subj: formula solver 2/7             Conf: (2) Quik_Bas```
```'>>> Start of page 2.

'   This function can expand factorials:
'
'       3! = 6
'       0! = 1
'
'   3. logical greater than, less than, and equality
'
'       5 > 4 = -1 [TRUE]
'       9 < 1 = 0  [FALSE]
'
'   4. nested parenthesis precedence override
'
'       5*(2+3) = 25 rather than 13
'
'   5. PASCAL style variable assignment (using the ":=" of PASCAL)
'
'       variable := 5+3  (assigns the value of 8 to variable)
'
'       Note also that variables that have been assigned can be used
'       within expressions:
'
'       newvariable := 3+variable  (assigns 11 to new variable based ' upon
'                                   variable having an assignment of 8)
'   So far, variables cannot be reassigned by the same expression they
'   occur in.  So, the following yeilds a faulty answer:
'
'   x := x + 1
'
'   6. and more!
'
'   I leave it to you to figure out what 6?9 solves to!
'   This FUNCTION can solve complex equations that mix all parts of the
'   above!  Try it out!  Break it to pieces!  Smoke it!  It's yours!
'

CONST ASSIGNMENT = ":="     ' This can be changed to suit your needs
' Using a simple = is possible, since ' logical
' equality is a double == with this parser,
' but the PASCAL standard := is easier to ' deal
' with as an assignment operator for some.

' Operator classes                   PRECEDENCE
'---------------------------------------------------
CONST POWER = "^]?**>><<"           ' FIRST
CONST MULTDIV = "*/\%"              ' SECOND
CONST ADDSUB = "+-"                 ' THIRD
CONST LOGICAL = "<>=&|~>==><==<<>"' FOURTH

CONST OperatorClass = 1
CONST DigitClass = 2
CONST VARMAX = 100

TYPE VariableType
Nom AS STRING * 30  ' variable name
Valu AS LONG        ' variable's value
END TYPE

' Variables global to this module...
DIM SHARED VarMem(VARMAX) AS VariableType
DIM SHARED VariPtr AS INTEGER
DIM SHARED OPERATOR\$
DIM SHARED expression\$
DIM SHARED TOKEN\$
DIM SHARED TypeToken
DIM SHARED Ptr AS INTEGER

'>>> Continued on page 3.

--- Maximus/2 2.01wb
* Origin: The Nibble's Roost, Richmond BC Canada 604-244-8009 (1:153/918)
```

Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET