Skip to main content
Participant
January 2, 2017
Question

Script for true or false answer?

  • January 2, 2017
  • 1 reply
  • 1383 views

Hi!

I'm trying to get a field to print a true or false answer. The field is supposed to get data from another field (which is a summary field) and state if its 65 or above and then print if it is or not.

I have tried the following script but cannot get it to work.

{

if (this.getField(” Summa ATS 1”) == 65 = true);

if (this.getField(” Summa ATS 1”) < 65 = true);

if (this.getField(” Summa ATS 1”) > 65 = false);

{

if (true) System.out.println(" True ");

if (false) System.out.println(" False ");

}

How can I get this to work?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 2, 2017

There are several major mistakes in your code.

First of all, the "=" operator is used for assigning a value, not for comparisons.

Also, you should not use curly quotes in your code. Only straight ones (single or double, doesn't matter).

In addition, you should not put a semi-colon after an if-statement. It basically renders it useless. It should be followed either by a single line of code or by a block of code, surrounded by curly brackets, which are executed when that expression is true.

You should also be aware that any logical operator will always return a Boolean value, that is either true or false, so there's no need to add an additional check to check if it's true...

This line:

if ((a==b)==true)

Is identical to this line:

if (a==b)

PS. Just noticed another problem. You're only accessing the fields themselves, not their values...

Participant
January 2, 2017

Hi!

Thank you for the answer.

I guess this code should be right then:

if (this.getField("Summa ATS 1").value < 64)

{

System.out.println("OK")

}

​But it doesn't print "OK"!?

try67
Community Expert
Community Expert
January 2, 2017

From where are you executing the code?

Are there any error messages?