Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can I use cosine and sin functions in a custom calculation script?

Community Beginner ,
Feb 08, 2022 Feb 08, 2022

I'm trying to write a javascript calculation in a PDF form using cos and sin functions but I can't get javascript math functions to work.  Any suggestions?

TOPICS
PDF forms
886
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
3 ACCEPTED SOLUTIONS
Community Expert ,
Feb 08, 2022 Feb 08, 2022

What do you mean you can't get them to work?  Here's the reference.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 08, 2022 Feb 08, 2022

No, I can't get it work.

 

I tried something simple like:

 

event.value=math.cos(0);

and

event.value=math.PI

 

but it didn't return anything.  No error either, it just didn't change the cell value from the last java formula I entered that did work.

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 08, 2022 Feb 08, 2022

Javascript is case-sensitive. Use Math. not math. 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 08, 2022 Feb 08, 2022

What do you mean you can't get them to work?  Here's the reference.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 08, 2022 Feb 08, 2022

No, I can't get it work.

 

I tried something simple like:

 

event.value=math.cos(0);

and

event.value=math.PI

 

but it didn't return anything.  No error either, it just didn't change the cell value from the last java formula I entered that did work.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 08, 2022 Feb 08, 2022

Javascript is case-sensitive. Use Math. not math. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 08, 2022 Feb 08, 2022
LATEST

That was simple, thanks!  

 

Here's the formula I'm using for converting a magnitude and angle to the X coordinate and it works great now:

 

event.value=this.getField("Magnitude”).value*Math.cos(this.getField("Angle").value/(180/Math.PI));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines