Clarification regarding Logical functions.



IBM's Command List programming language & Restructured Extended Executor

Clarification regarding Logical functions.

Postby Viswanathchandru » Tue Jan 22, 2013 3:02 am

Dear all,

I have a small logical function part which decides which one should be executed next. I was trying this from morning not sure if I'm wrong but seems the way I tried was correct. Its a very basic idea. The script counts the no of lines(1255) and if the value is less than 1255 and greater than 0 I need to execute some other function/para. I wrote the condition like this.

IF VAR4 << 1255  AND VAR4 > 0 THEN
  CALL FILMAN2
ELSE
CALL PAGEON


Trace shows the value of VAR4 is 1255 and hence the condition should fail and it should execute PAGEON para/function. But it gets a logical value =1( Trace output) and executes FILEMAN2. Please correct me if I'm wrong.


Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Clarification regarding Logical functions.

 

Re: Clarification regarding Logical functions.

Postby prino » Tue Jan 22, 2013 3:07 am

Ever thought about reading a manual? REXX \= COBOL!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: Clarification regarding Logical functions.

Postby Viswanathchandru » Tue Jan 22, 2013 3:13 am

Hi Prino,

Thanks for your time. I'm not understanding your thoughts. I can understand that Rexx is not like COBOL but why here?
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Clarification regarding Logical functions.

Postby enrico-sorichetti » Tue Jan 22, 2013 3:30 am

You were given already quite a few times the links to the Rexx manuals
did Yo ever care to use them ???

and why not use parentheses to show the logic

and why invent a logical AND operator when the & is more than enough ...

and why use the << which is the <strict> comparison operator

anyway here is what happens ...

rexx finds var4... <== shift
rexx finds an operator ( irrelevant if logical ) <== shift
rexx finds 1255 <== shift
rexx finds the " " abuttal operator <== shift
rexx finds the AND <== shift
rexx finds the < and ...
..... reduces the 1255 concatenation with the and
..... reduces the first comparison operator
which yields TRUE ==> the value 1
stacks the result, shifts the >
shifts the 0
at end of the statement
it reduces the comparison between 1 and 0
and finally it returns true

simply following the rules of the rexx grammar
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
Viswanathchandru (Tue Jan 22, 2013 3:54 am)
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Clarification regarding Logical functions.

Postby Akatsukami » Tue Jan 22, 2013 3:32 am

Viswanathchandru wrote:Dear all,

I have a small logical function part which decides which one should be executed next. I was trying this from morning not sure if I'm wrong but seems the way I tried was correct. Its a very basic idea. The script counts the no of lines(1255) and if the value is less than 1255 and greater than 0 I need to execute some other function/para. I wrote the condition like this.

IF VAR4 << 1255  AND VAR4 > 0 THEN
  CALL FILMAN2
ELSE
CALL PAGEON


Trace shows the value of VAR4 is 1255 and hence the condition should fail and it should execute PAGEON para/function. But it gets a logical value =1( Trace output) and executes FILEMAN2. Please correct me if I'm wrong.


Regards,
Viswa

Why did you use the "strictly less than" (<<) operator? Are you sure that VAR4 is strictly less than 1255?

Why did you use the word "AND" rather than the logical AND symbol (&)? The results will not be the same.

Did you trace execution displaying Intermediates or just Results?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Clarification regarding Logical functions.

Postby Viswanathchandru » Tue Jan 22, 2013 3:36 am

Hi Akatsukami,

Yes I'm Sure, VAR4 is strictly less than 1255.


Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Clarification regarding Logical functions.

Postby Akatsukami » Tue Jan 22, 2013 3:38 am

Viswanathchandru wrote:Hi Akatsukami,

Yes I'm Sure, VAR4 is strictly less than 1255.


Regards,
Viswa

Well, Dr. Sorichetti just explained why you're wrong, so perhaps you should be less sure.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Clarification regarding Logical functions.

Postby enrico-sorichetti » Tue Jan 22, 2013 3:42 am

Yes I'm Sure, VAR4 is strictly less than 1255.


if instead of replying to Akatsukami Sama You had read my post we would not be here wasting time :evil:

the AND is not a flucking REXX logical operator

run a snippet like

VAR4 = ...
trace "I"
say VAR4 << 1255
say VAR4 << 1255 AND
say VAR4 << 1255 AND > 0

and You will understand what is going on
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Clarification regarding Logical functions.

Postby enrico-sorichetti » Tue Jan 22, 2013 3:46 am

also meditate on the manual about the <strict> comparison operators

run this snippet and You will see the gotchas

numeric digits 4

if  "a" = "a   " then ,
    say one
else ,
    say two

if  "a" == "a   " then ,
    say one
else ,
    say two


a = 9999 + 9999

say a

say 19998 = a
say 19998 == a





as a general idea the strict operators do not carry on any <conversion> and act on the RAW variable strings
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
Viswanathchandru (Tue Jan 22, 2013 3:54 am)
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Clarification regarding Logical functions.

Postby Viswanathchandru » Tue Jan 22, 2013 5:26 pm

Thanks a lot enrico for your time.


Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post