WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Arrays
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Resize an Array


2010B and newer

Starting in WinBatch 2010B use the function ArrayRedim.
ArrayRedim ( array, sub1, [sub2, [sub3, [sub4, [sub5]]] )

Changes array dimensions in-place while preserving existing content when possible.

"array" array to re-dimension
"sub1" to "sub5" specifies the new "array" dimensions or -1 to keep existing dimensions.

The default for "sub2" through "sub5" is 0 which deletes the existing dimension.
Once an array dimension is set to 0, all subsequent array dimensions must be
set to 0 or omitted.  -1 can also be used  for subsequent dimensions if current
corresponding dimension is already 0.

Returns @True on successful completion.
See Also: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Arrays/Samples~from~Users+Array~Resize~Examples.txt


2010A and older

There have been occasional questions about how to resize an existing WIL array.

In general, WIL arrays are fixed in size at the point of the original ArrDimension function, and there is no provision for resizing the array afterwards.

Advice on this situation included over-allocating the original array to be able to handle any future adds.

Or allocating a new array of the desired size and a time-intensive copying of the data, array element by array element.

This situation has not changed, but simple, two line methods have been recognized that can easily and fairly quickly enlarge one and two dimensiopnal arrays.

  1. Add 1000 entries to the one dimensional array "MyArray"
    ArrayFilePut("tempfile.tmp",MyArray,@TRUE)
    MyArray=ArrayFileGet("tempfile.tnp","?",1000)
    
  2. Add 1000 rows and 40 columns to a two dimensional array "OtherArray"
    ArrayFilePutCSV("tempfile.tmp",OtherArray,@TAB,@TRUE,0)
    OtherArray=ArrayFileGetCSV("tempfile.tmp",1,@TAB,1000,40)
    

Article ID:   W16905
File Created: 2014:07:18:09:50:34
Last Updated: 2014:07:18:09:50:34