Algebraic Function Solver source for PB/DLL 6.0 Now Available 
Author Message
 Algebraic Function Solver source for PB/DLL 6.0 Now Available

Hello!

I have ported (and cleaned up) my ARDAF algebraic function solver code so that
it compiles under powerbasic/DLL 6.0.

All 1,800+ lines of it are available for anonymous FTP at:

    ftp://qtj.net/pub/source/powerbasic/rdf300.bas

ARDAF has been around since January of 1993.

Here are the introductory comments from the source file, in case you're
wondering what it is and what it does:

'                                   PUBLIC DOMAIN CODE
'
'                           author: Quinn Tyler Jackson, Ph.D.

'                           url:     http://www.*-*-*.com/ ~quinn/
'
'
'   Version 3.0 Notes (27 September 1999):
'   --------------------------------------
'
'   ARDAF has gone through many version changes since I first released
'   it back in January 1993.  (It has even been ported to C++.)
'
'   One of the reasons I've maintained this code for so long is that
'   I believe a recursive descent function evaluator serves the BASIC
'   programming community both by providing a practical, useful tool
'   and by providing a tutorial in the design and implementation of
'   what a lot of programmers may still consider some of the most
'   obscure code to follow - a parser and interpreter.  Perhaps one of
'   the handiest ways to get to know a programming language intimately
'   is to implement a parser in that language.  (Well, that's how I
'   learned to program in C++ after years of BASIC dialects, anyway.)
'
'   With v3.0, I have ported the engine to PowerBASIC/DLL 6.0 compatible
'   code, but I have not added any functionality to the engine.  My
'   coding style has differed over the years, so I have also attempted
'   to bring this code more to my present style, although I haven't
'   been entirely successful in this regard.
'
'   This code is intended to be compiled as a DLL, but if you compile as
'   an EXE, you can modify PBMAIN at the end of the file for testing. The
'   DLL version exports only two functions:
'
'       FUNCTION SolveExpression(_
'           expr AS STRING,_
'           ImagPart AS EXT,_
'           ErrorCode AS INTEGER) AS EXT
'
'       FUNCTION ArdafErrorMessage(ErrorCode AS INTEGER) AS STRING
'
'   SolveExpression is called as follows:
'
'       DIM result AS EXT
'       DIM ImagPart AS EXT
'       DIM ErrorCode AS INTEGER
'       DIM expr AS STRING
'
'       expr = "a[10]:=5; b:=100+10*2+a[2+8]; b*2+cos(b)"
'
'       result = SolveExpression(expr, ImagPart, ErrorCode)
'
'   If, upon returning, ErrorCode is 0, then result will contain the
'   numeric result of having solved the expression in expr.  If the function
'   solves to a complex number, ImagPart will contain the imaginary part
'   of the result.  If ErrorCode is less than zero -- you have been warned
'   that some default has been used, some undefined array element accessed,
'   or something else that defaults, but does not cause a termination.
'   If ErrorCode is greater than zero, the error was fatal.
'
'   You can get an English description of the error or warning by calling
'   the function ArdafErrorMessage and passing the code as the parameter.
'
'   The expressions that ARDAF can deal with can be quite opaque, and
'   need not be in the familiar "programmer-ese" format.  Consider the
'   following:
'
'       a(x) := 2x; b(x) := a(4x+i); b(2)
'
'   The above expression would be solved in three steps.  First, the
'   function a(x) would be defined as returning 2 times x.  Then, the
'   function b(x) would be defined as returning a(4x+i), and finally,
'   b(2) would be invoked.  Taken as a whole, the above would return
'   a result with a real and imaginary part, 16 + 8i.  When multiple
'   subexpressions are separated by semicolons, SolveExpression returns
'   the result of the rightmost expression.
'
'   ARDAF can accept expressions in a more algebraic format than a
'   compiler would, so that:
'
'       a:=5; b:=9; (5a + 1)(7b + 9a + i)
'
'   solves to 2808 + 26i.  Internally, this is actually expanded to:
'
'       a:=5; b:=9; (5*a + 1)*(7*b + 9*a + i)
'
'   It's important to note that 5a expands to 5*a, but a5 is a variable
'   name.  Also, a(5) is a function call, whereas (5)a is 5*a.
'
'   Because ARDAF can deal with complex math in standard format, it
'   may be possible to solve expressions that you weren't anticipating
'   having been solved.  Consider this:
'
'       f(x) := square_root(100 - 5x); f(25)
'
'   This solves to square_root(-25), or 5i, but long-time BASIC
'   programmers might expect otherwise on values of x greater than 20.

--
Quinn Tyler Jackson
http://www.*-*-*.com/ ~quinn/



Sat, 16 Mar 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. PB/DLL 6.0 - PBEDIT Bug found...

2. When was PB/DLL 6.0 released?

3. MS Word Template for PB/DLL 6.0

4. Telnet PB/DLL 6.0

5. need PB/DLL 2.0 dumb terminal source

6. MX Lookup with PB/CC or PB/DLL

7. TCPADDR for PB/DLL & PB/CC

8. Info on new PB/CC and PB/DLL

9. Announcing the JazzAge COM Wizard for PB/DLL and PB/CC

10. animated characters, speech input/output in PB/DLL and PB/CC

11. email enable PB/DLL-PB/CC using Outlook

12. SQL, ADO/OLE-DB programming in PB/DLL and PB/CC

 

 
Powered by phpBB® Forum Software