array access error

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
t57042
Posts: 148
Joined: Tue Mar 16, 2010 9:46 am
Location: belgium

array access error

Post 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 
Marin
Posts: 33
Joined: Tue Dec 20, 2016 1:39 pm
DBs Used: DBF
Location: Bulgaria, Sofia
Contact:

Re: array access error

Post 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
t57042
Posts: 148
Joined: Tue Mar 16, 2010 9:46 am
Location: belgium

Re: array access error

Post by t57042 »

Because i dont know the colums before runtime
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: array access error

Post 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]
Andrés González López
Desde Guadalajara, Jalisco. México.
t57042
Posts: 148
Joined: Tue Mar 16, 2010 9:46 am
Location: belgium

Re: array access error

Post by t57042 »

Both examples give twice column 4 or win.grid_1.DeleteColumn(1) gives the array error
t57042
Posts: 148
Joined: Tue Mar 16, 2010 9:46 am
Location: belgium

Re: array access error

Post by t57042 »

I solved the mistery:

the example compile correctly with hmg 3.3.1 but not with 3.4.3

Richard
Post Reply