What is the use of evaluate statement give example?

Showing Answers 1 - 3 of 3 Answers

ajay s baghel

  • Oct 16th, 2006
 

When we have to resort to different actions depending on the value of a variable:  we can use Evaluate-endevaluate. It is just like Switch case in C language.

Eg:

move '12' to Month.

evaluate Month

   when '12'    display 'you are right'

   when '01'    display 'it is not new year dear!'

   when other display 'try again Boy!'

end-evaluate.

So it will display three different strings depending on what is moved into the variable Month.

Max

  • Oct 17th, 2006
 

In short, evaluate is a replacement of nested-if.

If 1+1>2 then display '1+1>2 is wrong'

else if 1+1<2 then display '1+1<2 is wrong too'

      else display 'you are right'

      end-if

end-if

could be replaced by:

evaluate true

    when 1+1>2       display '1+1>2 is wrong'

    when 1+1<2       display '1+1<2 is wrong too'

    when other         display 'you are right'

end-evaluate.

  Was this answer useful?  Yes

susi

  • Nov 27th, 2006
 

The Evaluate statement can be used in replacement of Nested-IF statements. These are also potentially used by combining the logical operators.

FOR EG:

evaluate a > 100 and a < 500

   move 'good' to b

evaluate a > 500 or a < 1000

   move 'better' to b

evaluate a > 1000 or a < 5000

   move 'best' to b

end-evaluate.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions