FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Concatenate two fields in one xBrowse Column
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 04:11 PM
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.


I have tried this code but it does not work ..
Code (fw): Select all Collapse
 // 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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 05:48 PM
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 (fw): Select all Collapse
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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 06:26 PM
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


Code (fw): Select all Collapse
// 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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 07:07 PM

Rick

remove the quotes

{ || STARTDATE+ENDINGDATE }

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 08:09 PM
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 (fw): Select all Collapse
// 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


Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 09:35 PM

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
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 09:56 PM

Is startdate and endingdate fields a date type or character type.
You may need to convert them to character. { || ctod(startdate)+CRLF+ctod(endingdate) }

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Thu Jan 02, 2014 11:21 PM

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

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Concatenate two fields in one xBrowse Column
Posted: Fri Jan 03, 2014 01:05 AM

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

Continue the discussion