Can COLUMNFIELDS value be returned?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Red2
Posts: 281
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Can COLUMNFIELDS value be returned?

Post by Red2 »

My problem: Can COLUMNFIELDS value be accessed in a .PRG? For example:
ZZZ := getproperty( "Form_1","Grid_1","ColumnFields" )
or
ZZZ := Form_1.Grid_1.ColumnFields

TYPE() for the above returns "UI", "Error indeterminate". (See below)
Is my code the problem or is there some issue with HMG?

Example: "C:\HMG.3.4.4\Samples\Controls\Grid\GRID_13\Demo.PRG"
1) I increased the form's height to 600
2) and added the following BUTTON:

Code: Select all

DEFINE BUTTON GetColumnFields
	ROW    520
	COL    30
	WIDTH  200
	HEIGHT 30
	ACTION	msginfo( "ColumnFields value: "	+ Type( 'getproperty( "Form_1","Grid_1","ColumnFields" )' ) )
	CAPTION "Grid_1's ColumnFields?"
	TABSTOP .T.
	VISIBLE .T.
END BUTTON
QUESTION: Is it possible to programatically determine the value of COLUMNFIELDS?

Thank you!
Red2
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Can COLUMNFIELDS value be returned?

Post by Claudio Ricardo »

Hi Red2
Creo tendrías que hacer un bucle For-Next que verifique con ValType la primer Row del array con el que cargas el Grid.
Ya que Grid sólo muestra el valor sin importar el Type de su contenido.
Eng. Google translate:
I think you would have to do a For-Next loop that verifies with ValType the first Row of the array with which you load the Grid.
Since Grid only shows the value regardless of the Type of its content.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Can COLUMNFIELDS value be returned?

Post by AUGE_OHR »

hi,

not sure if it help you

Code: Select all

   aaa := ACLONE( _HMG_SYSDATA[ 326 ] )       // -> Current Control Definition: "ColumnFields"
   aStruc := DBSTRUCT()

   iMax := LEN( aaa )
   FOR i := 1 TO iMax
      cSeek := aaa[ i ]
      nPosi := ASCAN( aStruc, { | e | e[ DBS_NAME ] = cSeek } )
      IF nPosi > 0
         cType := aStruc[ nPosi ] [ DBS_TYPE ]
have fun
Jimmy
Red2
Posts: 281
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: Can COLUMNFIELDS value be returned?

Post by Red2 »

Hi Claudio and Jimmy,

Thank you for your kind suggestions. I appreciate them.
It still seems that there is no way to programmatically retrieve the value of GRID property COLUMNFIELDS.

According to HMG's debugger: _HMG_SYSDATA[ 326 ] returns NIL thus
ACLONE( _HMG_SYSDATA[ 326 ] )
does not return useful information.

Note: In this example the value of COLUMNFIELDS is not defined externally (outside of the GRID definition).
It appears that HMG cannot provide a GRID column's actual ROWSOURCE field specifics.
Am I wrong? Is there some way here to programmatically determine the .DBF field that a column displays?

(Google Spanish):
Gracias por sus amables sugerencias. Les agradezco.
Todavía parece que no hay forma de recuperar mediante programación el valor de la propiedad GRID COLUMNFIELDS.

Según el depurador de HMG: _HMG_SYSDATA [326] devuelve NIL por lo tanto
ACLONE(_HMG_SYSDATA [326])
no devuelve información útil.

Nota: En este ejemplo, el valor de COLUMNFIELDS no se define externamente (fuera de la definición de GRID).
Parece que HMG no puede proporcionar las especificaciones reales del campo ROWSOURCE de una columna GRID.
¿Me equivoco? ¿Hay alguna forma aquí de determinar mediante programación el field .DBF que muestra una columna?

Thanks again,
Red2
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Can COLUMNFIELDS value be returned?

Post by gfilatov »

Hi,

Please take a look for the HMG internal function below:

Code: Select all

************************************************************
Function GetFiledData ( index, nField )   // ADD May 2016
************************************************************
Local cRecordSource   := _HMG_SYSDATA [ 40 ] [ index ] [ 10 ]
Local aColumnFields   := _HMG_SYSDATA [ 40 ] [ index ] [ 11 ]
Local aColumnClassMap := _HMG_SYSDATA [ 40 ] [ index ] [ 30 ]
Local xData
   IF aColumnClassMap [ nField ] == 'F'
   // xData := &cRecordSource->( FieldGet( &cRecordSource->( FieldPos( aColumnFields[ nField ] ) ) ) )
      xData := &cRecordSource->&( aColumnFields[ nField ] )   //  Field in this Area
   ELSE
      xData := &( aColumnFields[ nField ] )   // Field in other Area
   ENDIF
Return xData
where 1st parameter index is the result of the function GetControlIndex ( GridName, ParentForm ).

Hope that give you some idea :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Red2
Posts: 281
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: Can COLUMNFIELDS value be returned?

Post by Red2 »

Thank you Grigory,

That information is exactly what I was not aware of and needed. I am very grateful.

Kindest Regards,
Red2
Post Reply