Author Topic: WinBatch & iGrid Arrays  (Read 6537 times)


  • Pundit
  • *****
  • Posts: 1948
    • Data & Stuff Inc.
WinBatch & iGrid Arrays
« on: January 15, 2017, 01:06:03 pm »
I asked about this years ago with no helpful responses and still haven't figured it out so thought I would ask again...

The iGrid grid has a LoadIntoArray() method which, as you might expect, will load the grid contents into an Array.  With WinBatch it simply crashes WinBatch.   No script error.

I have posted my code and then the help file for the Method.   Is there something special I need to do in defining the array to make this work?



Code: Winbatch
          If igrid.RowCount == 0 Then Break
          arr = ArrDimension(igrid.RowCount,igrid.ColCount)
          ArrInitialize (arr," ")

LoadIntoArray Method
Copies cell values into an 1-dimensional or 2-dimensional array.

Sub LoadIntoArray( _
   ByVal vStartRow As Variant, _
   ByVal vStartCol As Variant, _
   ByRef vArray As Variant, _
   Optional ByVal bColMajorOrder As Boolean = False _

vStartRow The numeric index or string key of the first row to copy cell values from.

vStartCol The numeric index or string key of the first column to copy cell values from.

vArray The array to copy cell values into.

bColMajorOrder A Boolean value that specifies how to treat the indices of the specified array. For a 2-dimensional array, indicates whether the first index should be treated as row index and the second index should be treated as row index (False) or vice versa (True). For an 1-dimensional array, indicates whether to treat it as a column and copy the vStartCol grid column starting from the vStartRow row into the array (False), or to treat the array as a row and copy the vStartRow grid row starting from the vStartCol column into it (True).


The LoadIntoArray method can be used to quickly copy iGrid cell values into an array. This method allows you to simplify your code and to provide much better performance than copying iGrid cell values in a loop by reading the CellValue property.

The method works with 1- and 2-dimensional arrays of any type. If you provide a 2-dimensional array in the vArray parameter, iGrid will copy the rectangular area of cells with the top-left cell in the row and column defined by the vStartRow and vStartCol parameters. If you pass a 1-dimensional array to the method, the iGrid column vStartCol or the iGrid row vStartRow will be copied depending on the value of the bColMajorOrder parameter.

The method automatically exports the row text column if the specified array has the corresponding column. For instance, if the grid has 5 main columns (its ColCount property equals 5) and you specify a 6-column array when calling LoadIntoArray, the 6th column of the array will be populated with the cell values from the grid's row text column.

Note that this method does not redimension the array to copy the specified cell values. If the specified array does not have enough rows or columns to accommodate all the cell values, the method skips the corresponding cells in the last rows and columns.

iGrid also checks whether the specified array can be used for population. If it is a non-initialized array or it has more than 2 dimensions, iGrid raises its internal "Invalid procedure call or argument" error.

Note that the array is passed as a Variant variable, which allows you to pass an array of any data type for processing. However, you can get the VB "Type mismatch" error during the call of the LoadIntoArray method if the data type of an iGrid cell value isn’t compatible with the base data type of the array.

This method can be used in pair with the LoadFromArray method to copy values from and into array for quick calculations in memory, etc.


1. Copy a whole iGrid control into a 2-dimensional array:

Dim arr(1 To 10, 1 To 5) As Variant
iGrid1.LoadIntoArray 1, 1, arr

2. Export the 3rd column of iGrid into an 1-dimensional array:

Dim arr(1 To 15) As Long
iGrid1.LoadIntoArray 3, 1, arr

3. Export the 2nd row of iGrid into an 1-dimensional array:

Dim arr(1 To 5) As String
iGrid1.LoadIntoArray 2, 1, arr, True


  • Pundit
  • *****
  • Posts: 1948
    • Data & Stuff Inc.
Re: WinBatch & iGrid Arrays
« Reply #1 on: April 26, 2017, 01:20:14 pm »
I think even the crickets have died...

Are there any questions or some information I could provide the iGrid folks about WinBatch arrays they might need to tweak things so I can make use of this functionality?




  • Full Member
  • ***
  • Posts: 125
Re: WinBatch & iGrid Arrays
« Reply #2 on: April 27, 2017, 12:28:39 am »
Don't use a Winbatch array?
Have you tried just passing it a pointer to a buffer or something?
Maybe it needs a safearray - I think there is a way of making one in the Tech Database.

Nothing sucks more than that moment during an argument when you realize you're wrong. :)


  • Tech Support
  • *****
  • Posts: 4440
    • WinBatch
Re: WinBatch & iGrid Arrays
« Reply #3 on: April 27, 2017, 06:50:21 am »
It is trivially simple to convert a WIL array to a safearray of variants.

a = ArrDimension(5,5)
sa = ObjectType('array|variant',a)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade


  • Pundit
  • *****
  • Posts: 1948
    • Data & Stuff Inc.
Re: WinBatch & iGrid Arrays
« Reply #4 on: April 29, 2017, 12:05:42 pm »
Nothing seems to work.   I've emailed them asking them what type of array is required and see if that provides any clues.