Page 1 of 1

Use of macro in browser creation

Posted: Sat Feb 25, 2012 5:09 am
by Janko
Dear Roger,

I use huge database containing different kinds of monthly data. All fields are named as 'koli01', 'koli02' ....'koli12', or 'neto01', 'neto02',....'neto12'.

I tried to replace extensive and repeating 'DCBROWSECOL ....' with macro operator:

Code: Select all

@ 3,1 DCBROWSE oBrowse ALIAS 'MATERI'                       ;
      SIZE 140 , 31  SCOPE   FREEZELEFT {1}                   ;
      PRESENTATION aPres

DCBROWSECOL FIELD MATERI->NAZIV ;
  HEADER "MATERIAL" PARENT oBrowse FOOTER '1'  EVAL { |o| o:colorBlock := dColor };
  SORT bSortCol      WIDTH 20

 FOR i:=12 to 1 STEP -1
		m->cVar:='MATERI->skoli'+StrZero(i,2)
    DCBROWSECOL DATA {||  &(m->cVar)}  ;
    HEADER "Količina "+aMes[i] PARENT oBrowse FOOTER StrZero(i,2)   WIDTH 10   PRESENTATION  bPres  PICTURE pic1
 NEXT i
but after forming GetList, GetSet block for a column created with macro (see: GetList [ ,31,1]) is containing uncompiled macro: {{ || &(m->cVar)}, .....} and oBrowse is showing column corresponding to last cVar.

Is there a way to avoid this?

Best regards
JAnko

Re: Use of macro in browser creation

Posted: Sat Feb 25, 2012 10:31 am
by skiman
Hi,

The following should work.

Code: Select all

FOR i:=12 to 1 STEP -1
    bBlock := &("{|| MATERI->skoli"+StrZero(i,2)+"}")
    DCBROWSECOL DATA bBlock  ;
    HEADER "Količina "+aMes[i] PARENT oBrowse FOOTER StrZero(i,2)   WIDTH 10   PRESENTATION  bPres  PICTURE pic1
NEXT i
Hope this helps. This way the codeblock is made within the For/next and with the correct value of i. In your code the value of i is always the last value.

Re: Use of macro in browser creation

Posted: Sat Feb 25, 2012 10:47 am
by Janko
Chris,

yes, it works. Thank you, best regards
Janko