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



>>  Barbara Morris  
>> You can count on M.PDATE staying in the same place.  Within your
>> program, a VARYING field has a fixed storage size (the maximum length of
>> the data plus two bytes).  If you do %SIZE on the field, you will always
>> get the same result no matter what the current length is.

Ouch, so you are saying if I declare a VARYING field to be 32767 which I 
routinely do, it takes 32K of storage? I thought the amount of storage was 
equal to the current string length + 2 bytes. If I do %LEN(string) = 0, the 
length of the string was zero. Are you saying that even though I set it's 
length to zero, it still occupies 32K of storage? 

Doesn't that kind of defeat of the whole purpose of VARYING? I thought the 
whole idea was that I could declare strings and not have to worry about these 
issues? What advantages would I get using VARYING over simply declare a string 
of 32K other than being able to say %LEN?

I routinely pass in varying string as parameters by value but I guess I hear 
that the system is going to have to copy the whole 32K to the stack?  

I know that %SIZE returns the maximum + two bytes but not that it was reading 
the actual length of the string. The compiler knows the maximum length of the 
string at compile time so that it would just insert the value at compile time. 
I was trying to think of a scenario were the compiler would not the maximum 
string length at compile time but can't think of one.  

I was thinking about this issue the other night and it seemed to me that best 
possibility was that each VARYING string always occupied 18 bytes. 2 bytes for 
the length and a pointer to the actual storage so if I set the value to zero, 
the storage was released. If I changed it to 20 bytes, I would have internally 
a pointer to the allocated storage but I guess you are saying no. This is done 
because doing allocations would take too much resources? 

Ouch, ouch. Going to have to change a lot of code.

As an Amazon Associate we earn from qualifying purchases.

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