× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: EVAL(?)
  • From: dhandy@xxxxxxxxxxx (Douglas Handy)
  • Date: Tue, 07 Mar 2000 08:09:03 -0500

Booith,

>But who would want that?  If I am changing '1234567890' to 'ABC'  I really 
>should expect '        ABC', not 'ABC       ' shouldn't I?  Something has 
>always seemed broken about that part of the Eval opcode.

I disagree.  EVAL is an assignment operator and rightfully changes the
(entire) left side of the equation to the value on the right.  I think
of MOVE more as a substring operator -- in the absence of the P
extender it only alters as many bytes as the Factor2 operand.

Let's say field X is a 10 byte character field, and for the sake of
argument, has the value '       ABC'.  Would you expect the following
statement to be true or false?

     C                   If        X = 'ABC'

Why or why not?  What about it you used this instead?

     C     X             Comp      'ABC'                    ...

I think you'll find most people would expect a character literal to be
padded on the right when used as an operand against a longer character
field.  The MOVE opcode is somewhat of an anomaly is this regard since
it doesn't (by default) perform any padding.  

We both know the COMP above would not test as equal since field X has
leading blanks.  On the presumption you agree the COMP should fail
than you should also agree changing the COMP to IFEQ should fail:

     C     X             Ifeq      'ABC'                    

Now if this IFEQ statement fails, it follows this variant should fail:

     C                   If        X = 'ABC'

Let's take this one step further.  Again, with X being a 10-byte
character variable, what you expect the result of this to be?

     C                   Eval      X = 'ABC'
     C                   If        X = 'ABC'

If, as you contend, the EVAL opcode should right-justify by default
then the following IF statement would fail, unless you also think the
COMP and IFxx opcodes should pad on the left.

To me something would seem *very* broken about the EVAL opcode if,
immediately after EVAL  X = 'ABC', an IF  X = 'ABC' tested as not
equal because X now was '       ABC'.

Yikes!  Try explaining that one to a non-RPG programmer.

Just my .02,
Doug
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.