Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm doing this graphing program in 1

Status
Not open for further replies.

Matilde

Programmer
Nov 30, 2001
18
0
0
DK
I'm doing this graphing program in delphi, but i was wondering how can you make the program draw functions that you input in an edit box....

Thanks!

Matilde... :O)
 
Could you explain in more detail what you mean by "draw function that you input in an edit box" or give an example? Clive [infinity]
 
I write a function ie. x^2/2+6 and then I want to draw the graph... But I can't do that because when I type in the function it's a string...
 
Is there always a fixed number of operands and operations? i.e. in your example there were 3 operands (2,2,6) and 3 operations (^,/,+)
You could perhaps drop a combo box (or one for each operation) on the form and populate so that it contains a drop-down list of all the available operations. Then you could drop several edit boxes (one for each operand) on the form. For example, the order of components which would allow you to enter the above formula would be: editbox - combobox - editbox - combobox - editbox - combobox - editbox. This way you can read each operand/operation individually. Clive [infinity]
 
With respect to Stretchwicksters idea, why dont you make a small keypad type display, like a calculator, that contains all of the keys and the operations that may be needed. Then as the user presses the keys / operation buttons, fill a label with the formula that is being created by the user.

Then you will have a formula at least in the form of a string value (label.caption), which you could parse through to get the individual operands and operations to use in your formula.

Hope this helps!

Andrew

"If it is stupid but it works then it isn't stupid"
 
The easiest way I have found to do math parsing in Delphi is to install the
"Microsoft Script Control" as an ActiveX compoment.

It handles all the basic math functions, plus things like trig and date-math.

You can set the language at runtime to either JScript or VBScript syntax.

Then it is as easy as:
[tt] MyVar:=ScriptControl1.Eval(Edit1.Text);[/tt]

It may already be on your system, try searching for something that looks like "msscript.ocx"

Or you can download from Microsoft, the (very long) url is:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top