Page 1 of 1

Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 4:11 pm
by Rick Lipkin
To All

I am trying to save space and was wondering if there is a way to concatenate two fields in one xBrowse Column. I have two dates .. startdate and enddate and would like to show them both in one column, one under the other as in the photo shopped screen below .. notice the Start End column, first row.
Image

I have tried this code but it does not work ..

Code: Select all

 // ad run in these publications
         REDEFINE xBROWSE oLbxC      ;
         RECORDSET oRsAdvtBill       ;
         COLUMNS "PUBLICATIONNAME",  ;
                 "STARTDATE"+CRLF+"ENDINGDATE",  ;
                 "WEEK1",            ;
                 "WEEK2",            ;
                 "WEEK3",            ;
                 "WEEK4",            ;
                 "WEEK5",            ;
                 "ACCOUNTEXECUTIVE", ;
                 "TOTALBILLED"       ;
         COLSIZES 57,70,26,26,26,26,26,50,75   ;
         HEADERS "Publication",      ;
                 "Start End",        ;
                 "W1",               ;
                 "W2",               ;
                 "W3",               ;
                 "W4",               ;
                 "W5",               ;
                 "AcctEx",           ;
                 "Total Bill"        ;
         ID 273 of oFld:aDialogs[1]  ;
         AUTOCOLS LINES CELL

         oLbxC:nMarqueeStyle := MARQSTYLE_HIGHLROW
         oLbxC:lRecordSelector := .f.
         oLbxC:lHScroll := .f. // turn off horiz scroll bar
         oLbxC:nRowHeight := 47
 
Any Advice would be appreciated.

Rick Lipkin

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 5:48 pm
by Richard Chidiak
Rick

You can do it, a code block for column definition { || STARTDATE+ ENDINGDATE }

then you will need to adapt the display of the column

something like

olbxc:aCols[2]:bPaintText := { |oCol, hDC, cText, aCoord| DrawText( oCol, hDC, cText, aCoord, TRANS, olbxc ) } // trans is a variable passed by my app

....

i join a sample of a function i use for drawing on several lines, hope it helps

Richard

Code: Select all


static function DrawText( oCol, hDC, cText, aCoord, TRANS, olbxc )
   local nTop  := aCoord[ 1 ], nLeft := aCoord[ 2 ]
   local nBottom := aCoord[ 3 ], nRight := aCoord[ 4 ]
   local nRow  := nTop
   local cLine, nFontHt, nAt

   nAt      := AT( CRLF, cText )
   if nAt > 0
      cLine    := Left( cText, nAt - 1  )
      TRANS[9][2]:Activate( hDC )  // font

      nFontHt  := GetTextHeight( oCol:oBrw:hWnd, hDC )
      SetTextColor( hDC, CLR_HRED )
      DrawTextEx( hDC, cLine, { nRow, nLeft, nRow + nFontHt + 4, nRight }, 1 ) //oCol:nDataStyle )
      SetTextColor( hDC, LIGHTBLUE )
      TRANS[9][2]:DeActivate( hDC )
      nRow     += nFontHt + 4
      cLine    := SubStr( cText, nAt + 2 )
   else
      cLine    := cText
   endif

   IF TRANS[11] = 4  // Planning Matériel
      TRANS[9][4]:Activate( hDC )
    ELSE
      TRANS[9][3]:Activate( hDC )
   ENDIF
   DrawTextEx( hDC, cLine, { nRow, nLeft, nBottom, nRight }, oCol:nDataStyle )
   IF TRANS[11] = 4  // Planning Matériel
      TRANS[9][4]:DeActivate( hDC )
    ELSE
      TRANS[9][3]:DeActivate( hDC )
   ENDIF
return nil
 

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 6:26 pm
by Rick Lipkin
Richard

Thank you for your quick response .. I inserted the codeblock just to see what output I would get and I don't think this is what was intended .. Let me know if I have done something wrong .. I thought I would at least get the two fields and then use your program to clean it up.

Rick Lipkin
Image

Code: Select all

// ad run in these publications
         REDEFINE xBROWSE oLbxC      ;
         RECORDSET oRsAdvtBill       ;
         COLUMNS "PUBLICATIONNAME",  ;
                 "{ || STARTDATE+ENDINGDATE }",;
                 "WEEK1",            ;
                 "WEEK2",            ;
                 "WEEK3",            ;
                 "WEEK4",            ;
                 "WEEK5",            ;
                 "FREQUENCYID",      ;
                 "ACCOUNTEXECUTIVE", ;
                 "TOTALBILLED"       ;
         COLSIZES 57,64,22,22,22,22,22,35,50,55   ;
         HEADERS "Publication",      ;
                 "Start Dt",         ;
                 "w1",               ;
                 "w2",               ;
                 "w3",               ;
                 "w4",               ;
                 "w5",               ;
                 "Freq",             ;
                 "AcctEx",           ;
                 "AmtBill"           ;
         ID 273 of oFld:aDialogs[1]  ;
         AUTOCOLS LINES CELL

         oLbxC:nMarqueeStyle := MARQSTYLE_HIGHLROW
         oLbxC:lRecordSelector := .f.
         oLbxC:lHScroll := .f. // turn off horiz scroll bar
         oLbxC:nRowHeight := 47
 

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 7:07 pm
by Richard Chidiak
Rick

remove the quotes

{ || STARTDATE+ENDINGDATE }

Richard

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 8:09 pm
by Rick Lipkin
Richard

Sorry about the quotes .. I re-compiled but I did not get any data with this code :( .. I am using Fwh1203 .. don't know if that has any bearing on the results.

Rick Lipkin

Code: Select all

// ad run in these publications
         REDEFINE xBROWSE oLbxC      ;
         RECORDSET oRsAdvtBill       ;
         COLUMNS "PUBLICATIONNAME",  ;
                 { || STARTDATE+ENDINGDATE },;
                 "WEEK1",            ;
                 "WEEK2",            ;
                 "WEEK3",            ;
                 "WEEK4",            ;
                 "WEEK5",            ;
                 "FREQUENCYID",      ;
                 "ACCOUNTEXECUTIVE", ;
                 "TOTALBILLED"       ;
         COLSIZES 57,64,22,22,22,22,22,35,50,55   ;
         HEADERS "Publication",      ;
                 "Start Dt",         ;
                 "w1",               ;
                 "w2",               ;
                 "w3",               ;
                 "w4",               ;
                 "w5",               ;
                 "Freq",             ;
                 "AcctEx",           ;
                 "AmtBill"           ;
         ID 273 of oFld:aDialogs[1]  ;
         AUTOCOLS LINES CELL

         oLbxC:nMarqueeStyle := MARQSTYLE_HIGHLROW
         oLbxC:lRecordSelector := .f.
         oLbxC:lHScroll := .f. // turn off horiz scroll bar
         oLbxC:nRowHeight := 47
 
Image

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 9:35 pm
by Richard Chidiak
Rick

Maybe the version , nevertheless you can do it in another way by calling a function in the columns definition

instead of { || STARTDATE+ENDINGDATE }

{ || FUNC1() }

....

STATIC FUNCTION FUNC1()
RETURN STARTDATE + ENDINGDATE

This will work as i use it since very long time, after you may format with a small function.

Note i would try startdate + crlf + endingdate not tested

Hth

Richard

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 9:56 pm
by Gale FORd
Is startdate and endingdate fields a date type or character type.
You may need to convert them to character. { || ctod(startdate)+CRLF+ctod(endingdate) }

Re: Concatenate two fields in one xBrowse Column

Posted: Thu Jan 02, 2014 11:21 pm
by Rick Lipkin
Richard and Gale

Thank you both .. been a long day and I am headed home. I will let you both know in the morning ..

Happy New Year!
Rick Lipkin

Re: Concatenate two fields in one xBrowse Column

Posted: Fri Jan 03, 2014 1:05 am
by Gale FORd
Sorry, should have been dtoc() not ctod()