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

simply trying to use a text string as a numeric value.....

Participant ,
Aug 09, 2017 Aug 09, 2017

I'm currently working on a script to automatically export my working files as a scaled down jpeg.

I want to be able to run the script, type in the percentage to be scaled down to and then have the script handle the rest.

I have most of the script working fine...... the only piece that I'm struggling with is getting it to parse the number I enter in the prompt box and use it as the percentage value to be scaled down to.
here are the relevant lines of code in my script.

app.preferences.rulerUnits = Units.PERCENT;

var Blah = prompt("percentage", "50");

newdoc.resizeImage(Blah, null, 300, ResampleMethod.BICUBICAUTOMATIC);

I can't figure out how to get it to use the number I type into the prompt box (var Blah) as the percentage to resize it.
if I type the number in here like this for example,

newdoc.resizeImage(88, null, 300, ResampleMethod.BICUBICAUTOMATIC);

as a number 88. I get expected results. it resizes my image to 88%

but if I typed 88 (or anything for that matter) in my "percentage" prompt box and try to use Blah as the first argument it just ends up resizing to 1px x 1px, no matter what I type.

Am I missing something here? I'm really at a loss, any help would be greatly appreciated!

TOPICS
Actions and scripting
589
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

correct answers 1 Correct answer

Guide , Aug 09, 2017 Aug 09, 2017

Try...

newdoc.resizeImage(Number(Blah), null, 300, ResampleMethod.BICUBICAUTOMATIC);

This will convert a string to a number.

Translate
Adobe
Guide ,
Aug 09, 2017 Aug 09, 2017

Try...

newdoc.resizeImage(Number(Blah), null, 300, ResampleMethod.BICUBICAUTOMATIC);

This will convert a string to a number.

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
Participant ,
Aug 09, 2017 Aug 09, 2017
LATEST

Thanks SuperMerlin, that's all I needed!

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