Skip to main content
Inspiring
April 11, 2013
Question

How to write in jsx "Not equal"?

  • April 11, 2013
  • 4 replies
  • 2426 views

i need to check, if all bleeds have the same value:

with (app.activeDocument.documentPreferences){

if (documentBleedBottomOffset==documentBleedTopOffset==documentBleedInsideOrLeftOffset==documentBleedOutsideOrRightOffset){

alert ("Make bleeds equal!"); exit()

}}

But if i try:

if (!documentBleedBottomOffset==documentBleedTopOffset==documentBleedInsideOrLeftOffset==documentBleedOutsideOrRightOffset){

nothing changes: line "alert" executes anyway. Why?

This topic has been closed for replies.

4 replies

JADarnell
Inspiring
April 11, 2013

Dmitry,

I did some experimenting on the console like so:

5==5==5==5

believe it or not, this came out false and that's because the first 5==5 was evaluated to true or 1 so the second comparison was actually 1==5 which was evaluated to false, or 0, and so on.

Interestingly enough, !5==5==5==5 in the console window was evaluated as false as well.  It wasn't until I did this:

!(5==5==5==5)

that the expression was evaluated as true.  That's because the internal expression was evaluated as false and the ! operator essentially flips the value to its opposite.

I think you want to refine your evaluation to something like this:

a = 11;

b = 10;

c = 10;

d = 10;

if(!(a == b && b == c && c == d))  //should evaluate to true

R,

John

BeliakovAuthor
Inspiring
April 12, 2013

Yes! Only this:

if(!(a == b && b == c && c == d))

does work properly.

Thanks, John.

Jongware
Community Expert
Community Expert
April 11, 2013

Muppet, you almost got me! But Bleed can be the same, even if the 'Make all settings the same' "checkbox" is not selected.

Dmitry, the proper syntax for "not x" is indeed "!x". But you need to use it on your entire expression:

if (!(documentBleedBottomOffset==documentBleedTopOffset==documentBleedIns ideOrLeftOffset==documentBleedOutsideOrRightOffset)) ...

-- note the extra set of parentheses.

Inspiring
April 11, 2013

Why don't you test the boolean… documentBleedUniformSize

Inspiring
April 11, 2013

'me' != 'you' //-> true

Edit:

Google loves us: http://www.w3schools.com/js/js_comparisons.asp