EXPAND/REDUCE/RESIZE

When writing a post in http://natural.forums.softwareag.com/viewtopic.php?p=1457#1457 about EXPAND/REDUCE/RESIZE of X-arrays I read the documentation more attentive and found out that these statements, at least for dynamic variables, are useless, as they have influence on the allocated storage, not the length of the value (*length is not modified unless the new allocated storage is less than the previous length of the value). The documentation says:

So, when you RESIZE (analog EXPAND/REDUCE) you advise NATURAL to reserve the specified space.

So after RESIZE you indeed can not rely on the specified space. I.e. what you did was useless.

To acquire the needed space and to reflect this in *length I am used to use MOVE ALL:

DEFINE DATA LOCAL                 
1 DYNVAR (A) DYNAMIC              
END-DEFINE                        
EXPAND DYNAMIC DYNVAR TO 70       
DISPLAY *LENGTH(DYNVAR) 'EXPAND'  
MOVE ALL ' ' TO DYNVAR UNTIL 70   
DISPLAY *LENGTH(DYNVAR) 'MOVE ALL'
END                               

But keep in mind that any following value assignment may change *length.

I am looking forward to the discussion!

Hi Wilfried;

To be quite honest, I had not seen the text you quoted. It would have disturbed me as well. I was under the impression that the main use for RESIZE was to “reserve” space for a variable before communicating with a subroutine of one sort or another.

The excerpt you quoted would seem to indicate RESIZE is worthless for this purpose. Perhaps SAG will elaborate.

steve

Wilfried
In the early days of NAT41 RESIZE was an performance issue if you increased a DYNAMIC in small pieces. With RESIZE if was possible to pre-allocate one big piece of storage. But in the meantime Natural has improved the resize algorithm so that the RESIZE is obsolete.
Only if you want to partially reduce a DYNAMIC the RESIZE is necessary. Because the only alternative to reduce a DYNAMIC is the RESET INITIAL.

Klaus