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




To paraphrase
a style is a style is a style
As far as the use of NOT is concerned, I will use it if I decide that THAT
is wanted
for example

chain keyfield fileA;
if not %found(fileA);
// The record HAS to be there. If not - then this is a MAJOR error
endif;

When NOT is not used then
chain keyfield fileA;
if %found(fileA);
else
// The record HAS to be there. If not - then this is a MAJOR error
endif;

In this instance (my opinion for what its worth) the use of not is much
more readable

Having said that, as already mentioned, I try to use select wherever
possible



Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill



Kurt Anderson
<kurt.anderson@cu
stomcall.com> To
Sent by: "'RPG programming on the IBM i /
rpg400-l-bounces@ System i'" <rpg400-l@xxxxxxxxxxxx>
midrange.com cc

Subject
03/01/2010 11:03 RE: More on RPG style
AM


Please respond to
RPG programming
on the IBM i /
System i
<rpg400-l@midrang
e.com>






There have been some comments about not issuing (or avoiding - to avoid
using the word "not") separate returns. In the case where I feel I need to
drop out of the procedure immediately instead of allowing logic flowing to
the end of the procedure, I'll typically create a "EndProc" subroutine
where I'll issue the Return and do any other end-of-procedure type stuff I
need done.

In regard to it being generally believed that "not" should not be used, I
guess I've overlooked that in the 8+ years I've been on this list. I tend
to believe that a procedure's return value, if an indicator, should be '1'
in the case where the procedure completed successfully.

If isInternational(phoneNumber);

However, there may be a case where I only care if it's not international.

If not isInternational(phoneNumber);

Of course, I could also have instead called the procedure isDomestic() so
the return value would reflect whether it was Domestic or not (instead of
whether or not it was International).

If that makes any sense.

I guess I do my best to allow for readability, and don't want my code to
have "not"s all over the place, but if I feel I need to use one, it doesn't
make me step back and question my code. (Maybe it should?)

Thanks
Kurt Anderson

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of David FOXWELL
Sent: Monday, March 01, 2010 4:44 AM
To: RPG programming on the IBM i / System i
Subject: More on RPG style

Hi,

I tend to divide my code into subprocedures in a program just to improve
readability, even when there is very little risk of that subprocedure being
called from anywhere else. Each subprocedure will correspond to a specific
task executed by the program.

Eg,

/FREE

IF not doThis ( )
RETURN

ENDIF;

IF NOT DoThat ( )
RETURN

ENDIF;

/END-FREE

In these cases I will use global variables unless not possible. That leaves
me with a load of one line prototype declarations in my code :

D doThis PR
D doThat PR

I've just discovered that this style seems to annoy at least one programmer
who prefers to see all the code in one main procedure and does not like to
see all those PR's PI's and returns, etc. Rather embarassing.

Am I justified in coding in this way or am I wrongly using subprocedures?
--
This is the RPG programming on the IBM i / System i (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.

--
This is the RPG programming on the IBM i / System i (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.