martedì 23 ottobre 2012

Operazioni aritmetiche e sintassi FormCalc in un pdf

Altre funzioni sono disponibili con il FormCalc di Adobe; in questo esempio una serie di operazioni di aritmetica selezionabili da una DropDownList tra cui un mix di operazioni inserite in una condizione "if then endif".
if ($.boundItem(xfa.event.newText) == "Addition") then
 sub1.TextField3.rawValue = sub1.TextField1.rawValue + sub1.TextField2.rawValue
elseif ($.boundItem(xfa.event.newText) == "Multiplication") then
 sub1.TextField3.rawValue = sub1.TextField1.rawValue * sub1.TextField2.rawValue
elseif ($.boundItem(xfa.event.newText) == "Division") then
 sub1.TextField3.rawValue = sub1.TextField1.rawValue / sub1.TextField2.rawValue
elseif ($.boundItem(xfa.event.newText) == "Subtraction") then
 sub1.TextField3.rawValue = sub1.TextField1.rawValue - sub1.TextField2.rawValue
elseif ($.boundItem(xfa.event.newText) == "Mix") then
 var total = Round(Abs((sub1.TextField1.rawValue / sub1.TextField2.rawValue)),2)
 sub1.TextField3.rawValue = Concat("€ ", total)
 if(Abs(total)>4) then
  xfa.host.messageBox("Value too high", "Attention", 3, 0)
 endif
endif
Output:
FormCalc in un pdf



Link di riferimento per funzioni e sintassi FormCalc:
http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf