gettingstarted
[Top] [All Lists]

Re: Equations supplied by user

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Equations supplied by user
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Mon, 31 Jan 2005 09:23:41 -0600
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <BE23F80C dot F5D%hugh dot neill at spitfireuk dot net>
At 2:58 PM +0000 1/31/05, Hugh Neill wrote:

I am an absolute beginner, except that I have worked the tutorial and
attempted to read various books.

I am trying to design a program part of which will evaluate a function
supplied by the user.

Wow, you're jumping right into the deep end. This is a very hard problem for a beginner. Val() does not do this for you, you have to work at it. Let me sketch out some approaches:

1. You can use an RBScript object. You'd need to feed it some source code that assigns the initial value of x, and then Prints the result of the expression the user entered. You'd get the answer in the Print event of the RBScript, which you could then display as you like.

2. You could write your own expression evaluator, probably using a simple recursive-descent parser. If this sounds like Greek to you, then you probably shouldn't attempt it until you get more experience under your belt. However, if you want to give it a try, I can send some sample code.

3. I believe that Bob Delaney has a plug-in that will evaluate expressions. Search the NUG archives. Bob has many math-related plugins, all very high quality and free.

Best,
- Joe

--
REAL World 2005 - The REALbasic User Conference
March 23-25, 2005, Austin, Texas
<http://www.realsoftware.com/realworld>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>