I am trying to set a field (call it "Result") to a complex calculation. I want to do something like this:

If DatabaseField:Type = "A" {

many lines of calculations giving Answer

} else if DatabaseField:Type = "B" {

many lines of calculations giving Answer

} else if DatabaseField:Type = "C" {

many lines of calculations giving Answer

} else if DatabaseField:Type = "D" {

many lines of calculations giving Answer

Put Answer into Database:Result

The question is, how do I do this in Filemaker? I would like to use constants and variables in my calculations but I cannot figure out how to do it? Should I use a script? Should I use the calculation window for a field? Can someone help me get started with the right syntax?

You can use a script step such as Set Field to assign the results of a calculation to your field.

You can define your Result field as a calculation field with your expression as its calculation.

You can define result as a data field (Date, text, number..) of a type appropriate to your result and specify the calculation as an auto-enter calculation.

Your expression in all cases would be structured like this:

Case ( DatabaseField:Type = "A" ; Result calculation goes here for Type A ;

DatabaseField:Type = "B" ; Result calculation for Type B ;

DatabaseField:Type = "C" ; Result calculation for Type C ;

DatabaseField:Type = "D" ; Result calculation for Type D ;

Result calculation if none of the above are true goes here (optional)

)