Concatenate two fields in one xBrowse Column

Post Reply
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Concatenate two fields in one xBrowse Column

Post 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
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Concatenate two fields in one xBrowse Column

Post 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
 
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Concatenate two fields in one xBrowse Column

Post 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
 
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Concatenate two fields in one xBrowse Column

Post by Richard Chidiak »

Rick

remove the quotes

{ || STARTDATE+ENDINGDATE }

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Concatenate two fields in one xBrowse Column

Post 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
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Concatenate two fields in one xBrowse Column

Post 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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Concatenate two fields in one xBrowse Column

Post 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) }
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Concatenate two fields in one xBrowse Column

Post 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
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Concatenate two fields in one xBrowse Column

Post by Gale FORd »

Sorry, should have been dtoc() not ctod()
Post Reply