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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to create dynamic functions? 1

Status
Not open for further replies.

josefl

Programmer
Nov 29, 2002
12
SE
Is it possible to load functions from a database or file at run-time. I'ld like for my users to be able to create their own functions. These functions can later be used by the program. Can this be done?
 
hi

What are you trying to achieve exactly? what kind of functions would you like them to create?

lou
 
Well, I want them to enter a function in the form of either:

function Squared(Number: Real): Integer; stdcall;
begin
Result:=Number*Number;
end;


Or in some other way, and then store it in a database or in a textfile. Do you think it's possible?
 
hi

I don't think you can do it so straight forward like that. I think you will have to do calculator type functionality on the interface and store the calculation 'instructions' in the database.

You could have a 'formula' field of type string in the db and link the record to input fields and output fields.

eg
formula table
id formulastring
1 'a*a' or 'sqr(a)'

input table
id fieldval field type
1 5 'real' this could be an id to a fieldtype table

Output table
id field type
1 'integer'

Also, you can you variants in your calculations.

Read in the formula and parse it. Then calculate using the input values and then format the output using the output value type. In this example you would use TRUNC on the resulting real type.

hope this gives you some food for thought anyway...
lou
 
I will try that innerfuse thing. It sounds awsome in the description. Thanks a bunch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top