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



eschew obfuscation

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Monday, December 09, 2013 2:45 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Alternatives to MOVEL - just curious

Kind of has me feeling like a lexical parser!!

This has 3 built-ins - I kind of want something with minimal calls to BIFs.

And that is coming from this guy who CAN put together some longish nested function calls - obfuscation contests, here we come!

Vern

On 12/9/2013 12:44 PM, Dave Shaw wrote:
Vern,

So would this be preferable?


num4 = %dec(%subst(%char(num6):1:4):4:0);

I'm not sure it's more readable at a glance, but if you read through it, I think it's pretty clear that it's saying 'Take the first 4 digits of the 6-digit number and plug them into a 4,0 number'. I'm not sure how it'll perform, but it can't be worse than division.


Is it worth what you paid for it? <grin>


Dave Shaw


________________________________
From: Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx>
To: RPG programming on the IBM i (AS/400 and iSeries)
<rpg400-l@xxxxxxxxxxxx>
Sent: Monday, December 9, 2013 1:32 PM
Subject: Re: Alternatives to MOVEL - just curious


I agree that this works - but it's like the old multiplication
technique to shift date formats. It was a trick, and prone to strange
looks until we knew the trick.

As is the division technique. And there you may have to rely on
precision rules of the calculation.

Of course, as Trevor Briggs said - documentation - comments, right? :)

Vern

On 12/9/2013 12:20 PM, Booth Martin wrote:
Num4 = Num6 * .01;

On 12/9/2013 10:31 AM, Vernon Hamberg wrote:
Hi y'all

I'm looking at some code - the purpose is to put the 1st 4 digits of
a 6-digit variable into a 4-digit numeric variable.

It is being done with the MOVEL opcode now.

I'm wondering about efficient alternative methods. One I can think
of is to use a data structure -

dcl-ds dsMoveL qualified;
num4 zoned(4);
num6 zoned(6) pos(1);
end-ds;

Anything simpler? Better performing?

I hope the syntax is right!! But you get the idea, right?

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.


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.