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



On 12/9/2013 11:31 AM, Vernon Hamberg wrote:
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?

As grotchy as it is, MOVEL at least hinted that the goal was to extract
some (or all) of one field.

If the case is that all rows containing NUM6 need to have the first 4
digits extracted, I favour the data structure. For an example, let's
say I was spinning through post-mortems of my SQL failures. SQLSTATE is
a 5 digit code, the first two of which are the class. 00 is normal, 01
is warning, etc. For nefarious reasons, I'm only interested in the
class, not the detail. Using a data structure makes it crystal clear to
me that the class is a subset of the whole.

I could use division or multiplication to extract the class but that
would be a side effect due to truncation as opposed to the primary
purpose of mathematical division. Decent names would hint at the intent
of division though.

--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.