Quote:
Originally Posted by ownedbycats
I'll give it a test in a few days
Two questions here. #purchasecost is a floating-point with format of $x.xx.
Code:
program:
if $$#purchasecost ==# '0.00' then '0.00'
elif $$#purchasecost <=# '0.99' then '$0.01 - $0.99'
elif $$#purchasecost <=# '4.99' then '$1.00 - $4.99'
elif $$#purchasecost <=# '10.00' then '$5.00 - $9.99'
elif $$#purchasecost <=# '15.00' then '$10.00 - $14.99'
elif $$#purchasecost <=# '15.00' then '$10.00 - $14.99'
elif $$#purchasecost <=# '20.00' then '$15.00 - $19.99'
elif $$#purchasecost <=# '30.00' then '$20.00 - $29.99'
elif $$#purchasecost >=# '30.00' then '$30.00 and up'
fi
a) This'll always try to show the first entry for undefineds. if $$#purchasecost ==# '' then '' best option?
b) More out of curiosity: The first time I made this template, I forgot to add the '#' to all the cmps. Line 11, >= '30.00', showed up on undefineds. This didn't happen for == or <=. How did it get 'undefined is more than 30.00'?
|
You are using raw_field ($$), in which case the format is ignored and an undefined number returns the string "none" instead of the empty string. The string "none" is larger than the string "30.00". If you want to check for undefined values then you should explicitly check for "none".
Alternatively, to control results you could use raw_field() explicitly to set what value you want for undefined. For example, you could say
Code:
v = raw_field('#purchasecost', -100000.00)
which sets v to -100000.00 if #purchasecost isn't defined. Then use the variable v in the if chain so that undefined numbers are very small and less than zero.
Finally, the last branch of the if shouldn't have a condition but should instead always return '$30.00 and up'. The test serves no purpose.