Prototyping does solve a lot of problem related to parameter passing.
Our standards were established before prototyping was an option.
"Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> 2008-03-31 14:45
This global rule that you have in your shop sounds a bit extreme for
me. I wonder how other handle this? (May be prototype is the answer).
My shop does not any have rule on parameter. However, I've heard quite
a few programmers here saying to always use character field as parameter
(redefine it and map it if you have to). I do not agree with it :).
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Denis Robitaille
Sent: Monday, March 31, 2008 1:36 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: Rép. : Classic Traps -- I need your input!
We have no field defined as packed in our DDS. All are defined as
zone.
For internal variable, we uses an external DS like this:
d e ds extname(myfile) prefix(d_)
based(d1)
And all program variables are define:
d p_var s like(d_var)
And, as a shop rule, we do not use database field as parameters. We
will define a variable for that:
p_var = var;
callp pgm(p_var);
So the fields from a file are used only for input/output for that
file.
For all other purposes, we use variable with standerdize prefix.
"Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> 2008-03-31 14:13
Yes. That is what I though you are referring to "A zoned field in a
file (In your op, you say a variable. I just want to make sure you mean
a field in the file)". The reason I ask is because your prescription
for this problem is to strictly use zoned (avoid packed
variable/field).
Are you saying that all numeric fields in all of your files are
defined as zoned? And your always use the extname for all files
declared in the RPG programs to force all those fields to remain zoned?
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Denis Robitaille
Sent: Monday, March 31, 2008 12:57 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: Rép. : Classic Traps -- I need your input!
Try it. You'll see. In fact, it can get even more confusing.
Here is more details.
You have an externally define file
Fmyfile if e k disk
It has a variable called : pakednbr 5p 0
you compile the program and look at the compile listing, you will see
pakednbr define as 5p 0
Now add the following lines to the program
D datastr ds
D pakednbr
recompile the program. Look at the compile listing and voila, the
internal definition of pakednbr has gone from packed to zoned. This
causes no problem except if you use the variable has a parameter
somewhere.
to make thing even worst, you get the same situation if pakednbr was
define zoned in the DDS of the file. (packed inside the program except
if part of a data structure)
I can not be sure why it is so, but it is so and it burned me in the
past.
"Lim Hock-Chai" <Lim.Hock-Chai@xxxxxxxxxxxxxxx> 2008-03-31 10:29
Denis:
I'm not sure why making a variable become part of the data structure
would change its attribute from packed to zoned.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Denis Robitaille
Sent: Monday, March 31, 2008 7:35 AM
To: RPG programming on the AS400 / iSeries
Subject: Rép. : Classic Traps -- I need your input!
<clip>
2. AN RPG programs works fine, you decide to make a variable that is
part of the parameters list part of a data structure. The variable was
defined as packed. After being added to the array, it is now zoned!!
Your programs start to bomb because it receives bad input. To avoid it,
what we did here is to avoied packed variable all together. The
performance impact, if any, is negligeible.
</clip>
--
This is the RPG programming on the AS400 / 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.
--
This is the RPG programming on the AS400 / 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.