It is also faster to use varying length fields than trimming off blanks from
a string.
When trimming off all characters (beginning from the last one) get checked,
while for varying length fields a "substring" gets performed for the number
of characters specified in the 2/4 leading bytes. If it is a big text field
which is only filled with a few characters, it may be time consuming. Also
when using EVAL to fill a field with fixed length all trailing characters
must be replaced with a blank. Because for varying length fields the length
of the string is stored in the first 2/4 Bytes it is not necessary to
replace the trailing bytes into blanks, i.e. they stay unchanged and get
overwritten the next time more characters get filled into the field.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Pete Hall
Gesendet: Friday, 11. September 2009 03:04
An: rpg400-l@xxxxxxxxxxxx
Betreff: Re: Use of VARYING fields
David FOXWELL wrote:
Hi,
I was asked why use this kind of variable. A part from tidying up the code
when concatenating text fields, I wasn't sure. The problem is that our data
dictionary is used in all our RPG sources and all zones are supposed to be
declared like a field in the dictionary.
Are there other advantages?
Thanks
They're very much like strings in most other languages, where char
fields are more like an array of char. Varying variables make string
manipulation (concatenation, character substitution, passing arbitrary
length values, program defined output buffering, empty strings, etc)
much easier. Try writing a parser, or managing a delimited data
structure with fixed length strings. You'll see the advantage.
As an Amazon Associate we earn from qualifying purchases.