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



<snip> What the
%indexsize (or %prefixsize, perhaps) would do is give you the number of
bytes in the prefix.

That way, you can code something like:

MaxDataLen = %size(MyVarFld) - %prefixsize(MyVarFld)

Right now people who mess around with this stuff are hardcoding this
value,
using things like "%size(MyVarFld) - 2", and this will break if a field
has
a 4-byte prefix. The %prefixsize BIF will return the size of the prefix
field.</snip>

True and using %prefixsize ( I like that BTW) removes the "magic number"
syndrome....


Thanks,
Tommy Holden


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Pluta
Sent: Thursday, May 17, 2007 12:25 PM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Max length of a VARYING field

From: Peter Dow (ML)

Hi Joe,

I agree with this scenario, with a couple of questions.

Why VARYING(x) as opposed to VARYINGx? The former implies (to me
anyway) that I can put whatever I want in there -- VARYING(1),
VARYING(7), etc.

You'll have to ask Scott and Barbara. Me, I like a big long name like
*MAX4GB, but Scott has opined that it's too much to type.


After all, I don't have to know the size of a disk sector in order to
read a record from a file.

That's why I like the idea of a VARYING with no size for those of us who
don't really care about the internals.


Later responses mention a %indexsize BIF. Index? It's a current
length
subfield isn't it?. How about %sizelen, or %lensize or something?
Unless it's considered an index to the end of the string...but I think
most people think of it as the current length, hence the %len BIF.

The %len BIF already gives you the current length (basically, it returns
the
value stored in the prefix). The %size BIF gives you the total size of
the
field, but that includes the prefix bytes (currently always 2). What
the
%indexsize (or %prefixsize, perhaps) would do is give you the number of
bytes in the prefix.

That way, you can code something like:

MaxDataLen = %size(MyVarFld) - %prefixsize(MyVarFld)

Right now people who mess around with this stuff are hardcoding this
value,
using things like "%size(MyVarFld) - 2", and this will break if a field
has
a 4-byte prefix. The %prefixsize BIF will return the size of the prefix
field.

Joe



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.