Expand my Community achievements bar.

Simple calculation FormCalc syntax

Avatar

Level 1

Afternoon all -

Hoping someone can help me with the formCalc syntax on an order form I'm putting together.  I'm sure this can be done relatively easily but I'm unsure if I should declare a variable and use that for further calculations, or if I'm heading in the right direction but just have the syntax incorrect.

Background: small bakery that makes pound cakes.  All of their ~30 flavors cost $25 for a whole cake, $15 for half, except for plain, which is $20 and $12, respectively. I'd like for the form to 1) detect the user's size choice, 2) detect the amount, and 3) calculate a subtotal per cake.  Additionally, I'd like to add the three subtotals boxes up to get an order total.

I'm using a drop-down list for the flavors. The Plain flavor is #29, and my non-working FormCalc code is as follows:

form1.main.totals.nbr_Total1::initialize - (FormCalc, client)

IF (form1.main.order_Details.order_Details1.list_Flavor[0]==29) and (form1.main.order_Details.order_Details1.list_Size==Whole)

          THEN (form1.main.order_Details.totals.nbr_Total1==20) OR

IF (form1.main.order_Details.order_Details1.list_Flavor[0]==29) and (form1.main.order_Details.order_Details1.list_Size==Half)

          THEN (form1.main.order_Details.totals.nbr_Total1==12)

          END IF

IF (form1.main.order_Details.order_Details1.list_Flavor[0]<>29) and (form1.main.order_Details.order_Details1.list_Size==Whole)

          THEN (form1.main.order_Details.totals.nbr_Total1==25) OR

IF (form1.main.order_Details.order_Details1.list_Flavor[0]<>29) and (form1.main.order_Details.order_Details1.list_Size==Half)

          THEN (form1.main.order_Details.totals.nbr_Total1==15)

          END IF

A screenshot that may makes things a little easier to understand:

http://goo.gl/Fwy3n

The working copy .pdf is available here, if that helps at all:  http://cgs2500.com/Order_form.pdf (not Reader-friendly yet)

I sincerely appreciate any help offered.  I'm not very well-versed in programming.

Thanks,

tadees

Added color to separate code

1 Reply

Avatar

Level 7

the syntax should be:

if (form1.main.order_Details.order_Details1.list_Flavor[0]==29 and form1.main.order_Details.order_Details1.list_Size==Whole) then
form1.main.order_Details.totals.nbr_Total1=20

elseif .... etc

endif