Hello I have this FormCalc if-then-else statement and I can't figure out where I am going wrong. I keep getting this error of a sytnax error near token 'then' on line 7. Prior to this I could only get the script to work for a maximum of 3 elseif's.:
The expression (1001 < WEIGHT < 2000) doesn't seem right for me. You may try something like:<br />"<br />if ( WEIGHT < 1000 ) then SHIP = 9.50<br />elseif ((1001<WEIGHT) and (WEIGHT<2000)) then SHIP=9.85<br />"<br />Henry<br />Adobe
When "4001 < WEIGHT" is evaluated, it amounts to a "true" or "false" value. Writing it the first way would essentially result in comparing "true" or "false" to 4500 which likely isn't what you want to do here.
The suggested way to write the expression boils-down to evaluating two boolean ("true" or "false") values together with an "and" operator which makes more sense (where the shipping cost is 13.50 only if the weight is both larger than 4001
and smaller than 4500).
This is most likely because you're assigning the value "POA" (a string) to a numeric field. Assigning a string value to a field which expects a numerical value always results in a translated numerical value of zero (0).
There are a few solutions I could suggest but I think the easiest one would be to use what's called a "compound" pattern for the Display Pattern property of the numeric field, located on the Object palette's Field tab.
Compound Display Patterns are patterns that include multiple "inner" patterns that tell a field how to display its data in different circumstances. For example, if the field's value (data) is null (no specified value -- not even zero), the field could display "POA" (text even though it's a numeric field). Otherwise, when the field's value is specified (not null), it could display it using a normal numeric pattern such as "$z,zz9.99".
So let's say you've already specified a Display Pattern of "$z,zz9.99" for the numeric field. You would change this Display Pattern into the following compound pattern:
Notice that the original Display Pattern has been preserved but now the compound pattern includes information on what to do when the field's value is null (not specified).
Given this compound pattern, when the postage goes above a given price, you would simply assign "null" as a value to the numeric field and it would automatically display a value of "POA" (even though it wouldn't actually have a value).
To set a field to null in FormCalc, you can do this: