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

Complex shorthand If Else breaks entire script in Illustrator 2018!

Explorer ,
Dec 26, 2017 Dec 26, 2017

!Consider following code

var a = 123;

var b = a === 123 ? 345 === 566 ? 123 : 444 : 567 === 567 ? 678 : 789;

alert(b)

This code excutes in chorme works.

However, it break in illustrator script !

The reason why I use such complex "if else", is because I use webpack UglifyJSPlugin to minify my script.

UglifyJSPlugin compiles my code to such complex "if else".

Is there any way to fix this ?

Is there any plugin I can use to transpile this code to normal if else ?

Thank you very much !

TOPICS
Scripting
1.1K
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

Explorer , Dec 26, 2017 Dec 26, 2017

Hey, other forum forward me this babel plugin

GitHub - OpenGG/babel-plugin-transform-ternary-to-if-else: Transform ternary operators (conditional expressions) into if…

This is exactly what I'm looking for.

Translate
Adobe
Community Expert ,
Dec 26, 2017 Dec 26, 2017

Hi JosephWang​,

sorry. I don't like such minimized codes. Hard to read and almost impossible to find mistakes in these codes.

But I think "Adobe Extendscript" is not Javascipt. Please try one of these slightly less minimized versions.

var a = 123;

var b = (a === 123 ? (345 === 566 ? 123 : 444) : (567 === 567 ? 678 : 789));

alert(b);

ifElseMinimizedComplex.png

Is this the result you want?

If not - please ask Kukurykus​ from PS-Scripting forum. He almost write all of his codes in this minimized kind.

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
Explorer ,
Dec 26, 2017 Dec 26, 2017

Hi, I totally agree with you.

I think I need to rethink about my question more time.

Thank you for your reply.

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 ,
Dec 26, 2017 Dec 26, 2017

Only for interest: what result should it be?

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
Explorer ,
Dec 26, 2017 Dec 26, 2017
LATEST

Hey, other forum forward me this babel plugin

GitHub - OpenGG/babel-plugin-transform-ternary-to-if-else: Transform ternary operators (conditional ...

This is exactly what I'm looking for.

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