Hi Dennis,

<snip>
But I'd need to research whether the %size() variable should actually be
reduced by the length of the length portion.
</snip>

%size() returns the number of bytes occupied by the variable. In this case it would be 58 for the 56a varying field. The length portion is included in the declared %size(). If it is forced to have a 4-byte prefix (using varying(4). It would then occupy 60 bytes and %size() would reflect this.

%len(), of course, contains the length of the data within the variable.

Thus (assuming the default prefix for a 56a varying field) %size would be 58 and invariant, %len would be anything from 0 to 56 - depending upon the data within the variable.

Now, if %size() was enhanced in 6.1 to also use *data then we could have had:


%len(Input_String) = RdLine(cli : %addr(Input_String:*data) : %size(Input_String:*data) : *on);

It wasn't so although we could avoid the use of VARPREF for the second parameter, it would still be needed for the third.

Further, in his example Scott checks for the return value being less than 1, not specifically equal to zero. This may suggest that a negative value could be returned. In this instance assigning the return value to %len() could result in some serious trouble.


At best we could have:

D VARPREF C CONST(2)





%len(Input_String) = %size(Input_String) - VARPREF;


len = RdLine( cli : %addr(Input_String:*data) : %len(Input_String): *On );


if (len < 1);


%len(Input_String) = 0;


else;


%len(Input_String) = len;


endif;




But this still assumes a 2-byte prefix and doesn't take account of a possible varying(4) declaration.



Cheers



Larry Ducie




_________________________________________________________________
Looking for a place to rent, share or buy this winter? Find your next place with Ninemsn property
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Edomain%2Ecom%2Eau%2F%3Fs%5Fcid%3DFDMedia%3ANineMSN%5FHotmail%5FTagline&_t=774152450&_r=Domain_tagline&_m=EXT

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 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].