Page 1 of 1

array access error

Posted: Mon Mar 06, 2017 1:47 pm
by t57042
I define a grid with 1 column (can one define grid without columns?)
I then delete that column and specify the columns outside the grid definition.
Why gives this line: win.grid_1.DeleteColumn(1) an array access error?

Richard

Code: Select all

#include "hmg.ch"
*------------------------------------------------------------------------------*
Function Main
*------------------------------------------------------------------------------*
 
 	Define Window win ;
		At 0,0 ;
		Width 500;
		Height 500;
		Title 'TABLE :  ' ;
		MAIN 		
    Define Grid Grid_1
			Row 0
			Col 0
			Width 500
			Height 500
		  Headers {"qq"}
		  Widths {10}       
		end Grid 
		
	End Window
  win.grid_1.DeleteColumn(1)
	
	for i =1 to 4
 	   win.grid_1. AddColumn ( i, "test"+alltrim(str(i)),50 ,BROWSE_JTFY_LEFT )         //headers
	next
  win.Center 
	win.Activate 
Return 

Re: array access error

Posted: Mon Mar 06, 2017 2:33 pm
by Marin
Hi,

Just a suggestion. Why not try first to add the 4 columns, and then delete the obsolete one?
This way you would keep the dimension of the grid in range, I suppose.

Regards,
Marin

Re: array access error

Posted: Mon Mar 06, 2017 2:54 pm
by t57042
Because i dont know the colums before runtime

Re: array access error

Posted: Mon Mar 06, 2017 3:27 pm
by andyglezl
Creo que deber de borrar la columna DESPUÉS de llenar el GRID
---------------------------------------------------------------------------
I think you should delete the column AFTER filling the GRID


O puedes hacer esto...
Teniendo en cuenta que en la columna 1 no tendrás datos.
----------------------------
Or you can do this ...
Bearing in mind that in column 1 you will not have data.

Code: Select all

		Define Grid Grid_1
			Row 0
			Col 0
			Width 500
			Height 500
			Headers {"."}	// <=====
		  	Widths {0}	// <=====   cero       
		end Grid 
		
	End Window
	// win.grid_1.DeleteColumn(1)		*Coment

O esto...
----------------------------------------------------------------------
Or this
----------------------------------------------------------------------

Code: Select all

#include "hmg.ch"
*------------------------------------------------------------------------------*
Function Main
*------------------------------------------------------------------------------*
 
 	Define Window win ;
		At 0,0 ;
		Width 500;
		Height 500;
		Title 'TABLE :  ' ;
		MAIN ON INIT FILLGRID()	
		
		Define Grid Grid_1
			Row 0
			Col 0
			Width 500
			Height 500
		  Headers {"qq"}
		  Widths {10}       
		end Grid 
		
	End Window
	win.Center 
	win.Activate 
Return 

FUNCTION FILLGRID()
	for i =1 to 4
 	   win.grid_1. AddColumn ( i, "test"+alltrim(str(i)),50 ,BROWSE_JTFY_LEFT )         //headers
	next
	win.grid_1.DeleteColumn(1)
RETURN

/code]

Re: array access error

Posted: Mon Mar 06, 2017 5:56 pm
by t57042
Both examples give twice column 4 or win.grid_1.DeleteColumn(1) gives the array error

Re: array access error

Posted: Mon Mar 06, 2017 6:19 pm
by t57042
I solved the mistery:

the example compile correctly with hmg 3.3.1 but not with 3.4.3

Richard