× 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.



I'm not Barbara but ...

You will do nicely, thanks! :)


On 10/04/2010, at 9:58 AM, Dennis Lovelady wrote:

But a question for you, Barbara: Won't the above code cause all
elements of
myNumbers to be filled with the value that's in myNumbers(1)?

Why so Grasshopper? The move does not reference array elements but
rather the containing the DS and thus becomes a simple byte copy from
[1 to (end - %size(mynumbers))] into [(%size(mynumbers)+1) to end].
RPG sorts out the length differences (i.e., the right operand is
longer than the length of the left operand and is truncated).

First off: it was a point of interest more than anything else. In very
simple terms, my understanding is that EVAL is roughly equivalent to MOVEL
in the same sense that EVALR is roughly equivalent to MOVE. This is the
basis behind my question. It also turns out to lead to invalid assumptions,
but just to justify where I was coming from... in a world where eval is
strictly a left-to-right operation, and where LEN = 1:
eval %Subst(mystring: LEN) = mystring ;
would seem to imply (since it's left-to-right) that byte 1 of mystring would
be moved to byte 2 of mystring; and then byte 2 of mystring would be moved
to byte3, et cetera, propagating the leftmost value throughout the length of
string. Values of LEN that are equal to some arbitrary "array element
length" would have the same effect: Elem2 = Elem1, then Elem3 = Elem2 and so
on.
These are both things we did as common practice for efficiently clearing
and/or initializing areas of memory in Assembler. It turns out (or appears)
that the MI is pulling some tricks under the covers.

I was really curious about this, so I tried the same thing, using MEMCPY, as
follows:
MemCpy %Addr(mystring)+1: %Addr(mystring): %Len(mystring)-1) ;
I expected this to be functionally equivalent to my old, trusty-dusty:
MVC OUTPUT,OUTPUT-1
Which is strictly a left-to-right operation. To my amazement, it didn't do
what I thought it would do... it had to switch to a Right-to-Left operation
in order to pull off what it did do, which was start with 01234567 and end
with 00123456.

To finally kill this thing off, I tried the opposite:
Memcpy %Addr(myString): %Addr(myString) + 1: %Len(myString)-1) ;
This translated to a Left-to-Right operation, since my result was 12345677.
(sigh.)

Usually I distrust a machine that tries to do what I want rather than what I
say. This is my first distrust of this particular family. So I wonder if
there's a way to do that old thing at all on AS/400, other than in a loop
where it's done by hand? I didn't try other languages, but given that
memcpy worked that way, I doubt it.

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
Hard work pays off in the future. Laziness pays off now.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.