That's why IBM gave us Monitor. In many circumstances the only error
that could occur is one such as described, so the On-Error can simply
repeat the Else code.
Trevor Briggs
Analyst/Programmer
Lincare, Inc.
(727) 431-1246
TBriggs2@xxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
j.beckeringh@xxxxxxxxxxxxxxxxxxxxxxxxxx
Sent: Monday, February 25, 2013 7:27 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: simple problem with string handling
Although I'm strongly in favour of using varying length strings, there
is
one thing that has bitten me a few times: substringing on a position
that
is outside the size of the string;
For example:
if %substr(path :1 :1) = '/';
// absolute path
else;
// relative path
endif;
will bomb if path is an empty varying length field. So it should be
something like:
if %len(path) >= 1 and %substr(path :1 :1) = '/';
// absolute path
else;
// empty or relative path
endif;
This example is easy enough to fix, but it gets messier when you have
something like '%substr(var :pos :len)'.
Joep Beckeringh
Scott Klement
IMHO, varying strings are much more elegant to work with. Even if it
doesn't save any CPU cycles, it just makes your code easier to write.
What's the advantage to sticking with fixed-length strings?