|
Hi Barbara, Well, I'll be flattered if I've come up with something here (but probably I haven't!). I'm trying to format a field for display on the screen -- if the user enters a value that contains an asterisk, I want to fill out the field with asterisks after that position before it's displayed again. This is motivated as much by trying to make things really clear for fumble-fingered users as any other real "need" to go this route, but in this situation it seems to work pretty well. Right now, I just define an array overlaying the field, search for an asterisk in the field, and then do MOVEA on the array. To me, this seems, well, just a whole lot slicker than the "for" loop. I admit that cryptic code sometimes is hard to understand, but as a former DIBOL and VB programmer I have come to appreciate some of the brevity that RPG/400 offered. (At the same time, I _really_ missed some of the features of those other languages that we didn't get until RPG IV -- that was (is) a great enhancement, and I love it. But I still like using MOVEs to put characters into decimal fields and vice versa -- I know I could use data structures or atol() or %EDITC, but MOVE is simple, and it works. And now I have this MOVEA thing. . .) What do you think? (and, thanks!) rpg400-l@midrange.com writes: >>Date: Mon, 14 Jan 2002 10:34:40 -0500 >>From: "Mike Naughton" <mnaughton@juddwire.com> >> >>I'm trying to join the twentieth century here and replace all my MOVEs >>with EVALs, but this one has me stuck. If I have a 9-element array RA >and >>I want to fill the last three elements with, say, "X", I can code: >> >>MOVEA *ALL('X') RA(7) >> >>Is there a way I can do the same thing using EVAL? > >Here's one way: > >C for i = 7 to %elem(RA) >C eval RA(i) = *all'X' >C endfor > >Here's another way that will probably perform somewhat better, >if the number of elements is very large (which it's not in >your case): > >D data s 65535a based(pData) >D pData s * >C eval pData = %addr(RA(7)) >C eval numElems = %elem(RA) - 7 + 1 >C eval %subst(data : 1 : %size(RA) * numElems) >C = *ALL'X' > >Mike, in an earlier thread, I made the bold claim that MOVEA was >a useless opcode, now that the string builtins are so powerful. >I challenged the mailing list to come up with a reasonable use >for MOVEA. Do we have a candidate here? What's the problem >being solved by setting those elements to 'X'? > >Barbara Morris Mike Naughton Senior Programmer/Analyst Judd Wire, Inc. 124 Turnpike Road Turners Falls, MA 01376 413-863-4357 x444 mnaughton@juddwire.com
As an Amazon Associate we earn from qualifying purchases.
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.