A grid.cell problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

A grid.cell problem

Post 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
Viva INTERNATIONAL HMG :D
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: A grid.cell problem

Post 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}
...
With best regards,
Sudip
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post 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
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post 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
Viva INTERNATIONAL HMG :D
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: A grid.cell problem

Post 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() 
With best regards,
Sudip
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post 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
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post 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
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: A grid.cell problem

Post 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: A grid.cell problem

Post 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
Viva INTERNATIONAL HMG :D
Post Reply