Page 1 of 3

A grid.cell problem

Posted: Thu Jul 29, 2010 2:03 pm
by esgici
Hi all

I have a big (for me) problem came from this little prg :(

Error BASE/1068 Argument error: array access

Called from _HMG_GETGRIDCELLVALUE(1548)
Called from GETPROPERTY(7196)
Called from SHOWG2CELL(124)
Called from (b)MAIN(46)
Called from _DOCONTROLEVENTPROCEDURE(5262)
Called from _SETVALUE(577)
Called from _DEFINEGRID(487)
Called from MAIN(46)


Where I'm wrong, any opinion ?

Regards

--

Esgici
GridTest.rar
For testing a grid.cell problem
(1.6 KiB) Downloaded 243 times

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 3:25 pm
by sudip
Hi Esgici,

It is because ShowG2Cell() is called before initialization.

Here is my quick and dirty solution :)
GridTest.zip
(136 Bytes) Downloaded 245 times
You may also try asigning value to grid_2 after END WINDOW

Code: Select all

...
END WINDOW
form_1.grid_2.value := {1, 1}
...

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 3:53 pm
by esgici
sudip wrote:
It is because ShowG2Cell() is called before initialization.

Here is my quick and dirty solution :)
Hi Sudip

Thanks, but the .zip include only .hbp, not .prg :(

... and not solved adding line to after END WINDOW too :(

Regards

--

Esgici

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 4:08 pm
by esgici
Sorry :cry:

Your trick prevent error for only first (initial) calling of ShowG2Cell() :(

Please try select any cell in Grid_2 after program run.

--

Esgici

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 4:23 pm
by sudip
Yes Esgici,

You are correct. I was wrong.

May be grid with table works differently than array grid.

Again my very dirty solution: :lol:

Code: Select all

PROC ShowG2Cell()

   aValue := This.Value
   
   nRow := aValue[ 1 ]
   nCol := aValue[ 2 ]
      
   cContent := test->(fieldget(ncol)) //this.Cell( nRow, nCol )
   
   MsgBox( cContent )   
    
RETU // ShowG2Cell() 

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 4:46 pm
by esgici
sudip wrote: Again my very dirty solution: :lol:
Yes, it's :lol:

Sadly, this is my principal problem : when changing row of grid, record of table doesn't change always :shock:

And I want understand when they are change and when not; and how I can setup a "synchronism" between rows of grid and records of table :(
Sudip wrote:May be grid with table works differently than array grid.
The sample has this two kind of grid for emphasize this point ;)

All comment and suggestion are welcome :)

Regards

--

Esgici

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 5:51 pm
by mol
I've tried to resolve this problem, but any idea comes to my head. Maybe tomorrow the solution becomes. Sometimes you need to sleep with problem to resolve it.
Marek

Re: A grid.cell problem

Posted: Thu Jul 29, 2010 5:55 pm
by esgici
mol wrote:I've tried to resolve this problem, but any idea comes to my head. Maybe tomorrow the solution becomes.
Thanks, I'll wait :)
mol wrote: Sometimes you need to sleep with problem to resolve it.
Yes, if you can sleep together problem :(

Regards

--

Esgici

Re: A grid.cell problem

Posted: Fri Jul 30, 2010 6:19 am
by mol
I was reading sources of HMG and It looks that internal table of GRID is not initialized when ROWSOURCE is declared. So you can not use phrase:

Code: Select all

cContent := this.Cell( nRow, nCol )
to retrieve data from database driven grid.

I've modified a little your function. It was necessary to call _HMG_SysData table to retrieve some data.

Code: Select all

PROC ShowG2Cell() 
	local i
	local aValue, aColumnFields, cField
	local cContent
	local nRecNo

	if lInitTime
		return
	endif
	
	aValue := This.Value
	nRow := aValue[ 1 ]
	nCol := aValue[ 2 ]
	
	i := GetControlIndex ( This.Name , ThisWindow.Name )
	xSelect := _HMG_SYSDATA [ 40 ] [ i ] [ 10 ] 
	if valtype(xSelect) = "C"
		// database driven grid
		aColumnFields := _HMG_SYSDATA [ 40 ] [ i] [ 11 ]
		nRecNo := GetProperty(ThisWindow.Name, This.Name, "RecNo")
		goto nRecno
		cField := aColumnFields[nCol]
		cContent := &cField
	else
		cContent := this.Cell( nRow, nCol )
    endif
	MsgBox( cContent )   
	
RETU // ShowG2Cell() 
PS. Didn't I write you should asleep with problem? :D

Besides, I think it should be easier way to retrieve data from grid based on database, not table. It's next job for Roberto :)
Best regards, Marek

Re: A grid.cell problem

Posted: Fri Jul 30, 2010 8:36 am
by esgici
Thanks a lot Marek, I'll try ...
mol wrote: PS. Didn't I write you should asleep with problem? :D
:D
mol wrote: Besides, I think it should be easier way to retrieve data from grid based on database, not table.
I'm afraid I couldn't understand this point. What is difference database and table ?

Regards

--

Esgici