Skip to main content
Participant
July 24, 2024
해결됨

Simple Calculation Script

  • July 24, 2024
  • 1 답변
  • 1233 조회

Hi! I'm pretty new to the idea of making calculation scripts in Adobe Acrobat, just to preface.

 

I'm trying to calculate the Time Value of Money and when I do the calculation with only the numbers it works out perfectly but as soon as I plug in my variables that equal those numbers my calculation no longer gives me the number it's supposed to. Here's the script I'm working with as a Simplified Field Notation.

 

c2 * ( 1 + 0.05 / 1 ) ^ 67 - Nn + a1 * c1 /0.05 ( ( 1 + 0.05 / 1 ) ^ 67 - Nn -1) * 1 

 

Nn = 30

a1 = 50,000

c1 = 10%

c2 = 1,000

 

I appreciate any help, thanks!

이 주제는 답변이 닫혔습니다.
최고의 답변: try67

Thank you. I've been working on it a bit more and this is what I have. It's still not coming up with any numbers.

 

var Cc = Number(this.getField("Cc")); console.println("Cc "+ Cc); var Ca = Number(this.getField("Ca")); var a1 = Number(this.getField("a1")); var Nn = Number(this.getField("Nn")); var first_pwr = Math.pow( event.value = Math.pow((Ca * ( 1 + 0.05 / 1 ) , ( 67 - Nn ) + ( a1 * Cc ) / 0.05 * ( ( 1 + 0.05 / 1 ) ,( 67 - Nn ) - 1 ) * 1 ));


- You forget the .valueAsString part in the definitions of the variables.

- Not sure why you stuck event.value in the middle of the last line. It needs to be at the start of it.

- Since your formula is a bit complex I would recommend splitting it into parts. Each part can be defined as a variable and then use later on in the final calculation.

1 답변

try67
Community Expert
Community Expert
July 24, 2024

You can't use the Simplified Field Notation if you need to use the Power operator. You must use a script.
And the way to do that in JS is with this command:

Math.pow(x,y)

This will return x^y.

Also, you need to make sure that the value of your percentage field is not 10 but 0.1, for the calculation to work correctly.

Reilly.H작성자
Participant
July 24, 2024

Thank you so much. Does my calculation have to change much to convert into Javascript? I have not worked in Javacsript before, only HTML and css.

Reilly.H작성자
Participant
July 24, 2024

- You forget the .valueAsString part in the definitions of the variables.

- Not sure why you stuck event.value in the middle of the last line. It needs to be at the start of it.

- Since your formula is a bit complex I would recommend splitting it into parts. Each part can be defined as a variable and then use later on in the final calculation.


That worked! Thank you!