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

Can I do math in a photoshop script?

Participant ,
Jan 12, 2023 Jan 12, 2023

Copy link to clipboard

Copied

I want to compute some object components based on a "prompt" input.

Thanks

TOPICS
Actions and scripting

Views

194

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jan 12, 2023 Jan 12, 2023

@mangurian 

 

Some references to common JS math methods:

 

https://www.w3schools.com/js/js_math.asp

 

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

 

Two things to keep in mind:

 

1) Adobe ExtendScript does not support "modern" features

 

2) Digits entered into a prompt are returned as a string, not a number:

 

var input = prompt("enter a number", "2");
alert(input.toSource());

 

However, in practice, JS often deals with this gracefully:

 

var input = prom
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 12, 2023 Jan 12, 2023

Copy link to clipboard

Copied

LATEST

@mangurian 

 

Some references to common JS math methods:

 

https://www.w3schools.com/js/js_math.asp

 

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

 

Two things to keep in mind:

 

1) Adobe ExtendScript does not support "modern" features

 

2) Digits entered into a prompt are returned as a string, not a number:

 

var input = prompt("enter a number", "2");
alert(input.toSource());

 

However, in practice, JS often deals with this gracefully:

 

var input = prompt("enter a number", "2");
var result = input * 2;
alert(result.toSource());

 

Hope this helps. 

Votes

Translate

Translate

Report

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