import statement + functions

Discussion created by cbgthor624 on Jan 31, 2013
Latest reply on Feb 20, 2013 by CWilkins-esristaff

I have a set of metrics I need to derive from measurements of the geometry of a massing model. The method for calculating those metrics is defined as a function with cga. However, the massing model is created by one of a dozen imported cga files, with the parameter required for the function calculated using rules in those cga files. Is it possible define a function in a "master" cga file, and use that function in an imported cga file with a parameter defined in the imported cga file?

This is the logic of it, roughed out in CGA:
## importing.cga
attr function(parameter) = parameter*someCalculation
import importedcga: "rules/imported.cga"  (function)
import importedcga2: "rules/imported2.cga"  (function)
Rule --> 
case someCondition == True: importedcga.importedRule
case someOtherCondition == True: importedcga2.importedRule
else: NIL

## imported.cga
attr parameter = 0 #empty attribute (to be set within this cga's rule).
attr function = 0 #empty attribute (overwritten by the import statement in importing.cga)
importedRule --> 
set(parameter, geometry.area)
report("metric", function(parameter))

So far I haven't had much luck in actual finding a solution. The way around doing this is to keep a copy of all functions in each of the imported.cga files...but I was hoping to avoid that so I wouldn't have to edit them all if I need to add other metrics or adjust any of the constants used by the calculations.

Thank you in advance,