× 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 31/03/2008, at 11:16 AM, Joe D wrote:

FYI - I like to think I am near the middle of the two extremes, but in truth
I think I definitely lean toward the Always Rewrite side. When I come
across ugly code I find it hard not to replace it with something prettier or
more efficient. For example, yesterday I replaced 30+ lines of code that
determined the 'Quarter Number' for a given month. The routine worked just
fine, but it still bothered me... There are a dozen ways it could be done,
but I chose to use a pretty one-liner: Quarter=%div(Month:4) + 1;

Hmm ...

D month S 5I 0
D quarter S 5I 0
d result S 50

C for month=1 to 12 by 1
C eval quarter = %div(month:4) + 1
C eval result = %char(month)+'='+%char(quarter)
C result dsply
C endfor

C seton LR
C return

Gives:

DSPLY 1=1
DSPLY 2=1
DSPLY 3=1
DSPLY 4=2
DSPLY 5=2
DSPLY 6=2
DSPLY 7=2
DSPLY 8=3
DSPLY 9=3
DSPLY 10=3
DSPLY 11=3
DSPLY 12=4

Classic trap?


Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




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.