Page 1 of 1

DCBROWSE field definitions in array

Posted: Fri Feb 20, 2015 6:41 am
by Victorio
Hi,
Please,how I can make this ?
I have in Clipper source field and header definitions in arrays, in eXpress I can only use headers, but fields break with error.

My source here:
SELECT 1
use datax index datax

* prku is names of database fields
* hrku is names of header columns

PUBLIC prku[3],hrku[3]
*DECLARE prku[3],hrku[3]

prku[1]="POR"
prku[2]="N_KATUZ"
prku[3]="K_KATUZ"

hrku[1]="Por.č."
hrku[2]="Názov k.ú."
hrku[3]="Kód k.ú."

@ 1,1 DCBROWSE oBrowse ;
SIZE 77,11.8 ;
CURSORMODE XBPBRW_CURSOR_ROW ;
ITEMSELECTED {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

DCBROWSECOL FIELD 1->POR ;
HEADER hrku[1] PARENT oBrowse

DCBROWSECOL FIELD 1->N_KATUZ ;
HEADER hrku[2] PARENT oBrowse

etc...

but I Want write some like this (in CA Clipper it run normally)

DCBROWSECOL FIELD 1->prku[1] ;
HEADER hrku[1] PARENT oBrowse

DCBROWSECOL FIELD 1->prku[2] ;
HEADER hrku[2] PARENT oBrowse

etc...

error is BASE/8027 Unknown symbor for database field...
I tryed @, &, before array name, but same error...

Re: DCBROWSE field definitions in array

Posted: Fri Feb 20, 2015 7:07 am
by messaoudlazhar
Hi,
Trying to use the following syntax :

DCBROWSECOL DATA {|| prku[1]}
HEADER hrku[1] PARENT oBrowse

Best regards,
Messaoud Mohamed Lazhar

Re: DCBROWSE field definitions in array

Posted: Fri Feb 20, 2015 8:00 am
by skiman
You also need to use the ALIAS parameter of dcbrowse.

Re: DCBROWSE field definitions in array

Posted: Fri Feb 20, 2015 8:08 am
by rdonnay
The below code is a sample program that will show you how to use array definitions for browsing a database.
Compile and run the program to see how it works.

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], GetOptions, oBrowse, aFields, i, cAlias

USE \exp19\data\Xtest
cAlias := Alias()

aFields := XTEST->(dbStruct())

@ 1,0 DCBROWSE oBrowse ALIAS cAlias SIZE 100, 20 ;
      PRESENTATION DC_BrowPres() ;
      FONT '9.Lucida Console'

FOR i := 1 TO Len(aFields)
  DCBROWSECOL DATA DC_FieldWBlock(aFields[i,1],cAlias) ;
    PARENT oBrowse HEADER aFields[i,1]
NEXT

DCREAD GUI FIT TITLE 'Browsing Database'

RETURN nil

PROC appsys ; RETURN

Re: DCBROWSE field definitions in array

Posted: Fri Feb 20, 2015 12:35 pm
by Victorio
Thanks ,
this running fine :

DCBROWSECOL DATA DC_FieldWBlock(pic[1],"1") WIDTH 10;
HEADER hic[1] PARENT oBrowse
where "1" is my "alias" of table, because I am using SELECT 1, SELECT 2,... numbers are aliases.

I do not like write names of field and headers anywhere, but I have it in header of function, where I have it on one place and with several function for example :
piv[1]="KN_PCS"
piv[2]="tucpopis(KN_TUC)"
piv[3]="substr(KN_VLA,1,50)"
...

Roger, I do not want browse every fields from table (table has many fields, but user do not need view all), I want browse only several important fields which user can see in one of dialogs.

Re: DCBROWSE field definitions in array

Posted: Fri Feb 20, 2015 4:19 pm
by rdonnay
Roger, I do not want browse every fields from table (table has many fields, but user do not need view all), I want browse only several important fields which user can see in one of dialogs.
It will only browse those which are in the array.

Re: DCBROWSE field definitions in array

Posted: Sat Feb 21, 2015 12:05 am
by Zdeno Bielik
Hi,

in one of the messages that I sent to your private e-mail in last weeks, also includes such examples
just carefully see attached examples there and try play with examples in demo and in eXpress’s help


aBrowse := { ;
{ 'PSČ', { || OBCE->PSC } }, ;
{ 'Obec', { || OBCE->OBEC } }, ;
{ 'Okres', { || OBCE->OKRES } }, ;
{ 'Kraj', { || OBCE->KRAJ } } ;

nMax := Len( aBrowse )

For ix := 1 To nMax
DCBROWSECOL DATA aBrowse[ ix, 2 ] HEADER aBrowse[ ix, 1 ] PARENT oBrowse
Next


Zdeno

Re: DCBROWSE field definitions in array

Posted: Sat Feb 21, 2015 5:23 am
by Eugene Lutsenko
Or maybe choose a array of information only those fields that you want to display?