Here's the twist. My current code is a multi-line segment. Something like
Cost = Qty * UnitCost
Tax_Cost = (Cost * Tax_Rate/100)
SubTotal = Cost + Tax
Overhead_Cost = SubTotal * (Overhead_Rate/100)
Markup_Cost = (SubTotal + Overhead_Cost) * (Markup_Rate/100)
Total_Cost = SubTotal + Overhead_Cost + Markup_Cost
Yup, storing those in a memo field would work just fine. I do this
stuff all the time in my metadata-driven visual classes.
I would use ALINES() to get each line into an array, and then tack on
an extra column for the results of each calculation. As Joel says,
then you could assemble a text string that can run as a macro. It
should be pretty straightforward to parse each line and substitute
the appropriate field data into the line in place of the field names.
Since it's all numbers and operators, you don't have to mess around
making sure you're quoting or not quoting things as needed. You would
just need to TRANSFORM() the numeric data as it comes out of the table.
Now you can loop through the array and do something like:
LOCAL CurrentFormula
CurrentFormula = LTRIM(SUBSTR(aArray(x,1),AT(aArray(x,1),"=")
aArray(x,2) = &CurrentFormula
INSERT INTO curReportData (Variable,Result) VALUES
(LEFT(aArray(x,1),,AT(aArray(x,1),"=") - 2),aArray(x,2))
Something like that anyway. Not tested. Be very afraid. You could
preprocess the lines a little more, add another column to the array
to store the name of the results variable so you aren't SUBSTR-ing
and AT-ing all over the place in the loop code, etc.
Anyway, what I'd do would end up looking something like that.
Ken Dibble
www.stic-cil.org
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/E7.10.32484.D5BCB465@cdptpa-oedge01
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.