Page 1 of 1

Add a extra option to the method ToCSV

PostPosted: Wed Sep 23, 2020 7:41 pm
by Marc Venken
METHOD ToCSV( cFile, aCols, lHeaders, cTrue, cFalse ) CLASS TXBrowse

I looked into the code of Xbrowse to find out how ToCsv is working. I see that the delimeter is hard code as a comma ( , )
I need i to be ( ; )

Is it a idea to add this option into Xbrowse source ? (extra : cDelimiter)

Or is there a other way ?
I prefer NOT to change source of FWH in order to keep the updates.

I do have read that it is possible to subclass from a source of FWH.
Just out of interest how this could work for my learning curve, maybe someone can use this code from source (Xbrowse) and make this work

I just named it MY_ToCSV (reference that it is My version) Then I can change the "," into ";" without Mr. Rao to change the sources of FWH


Code: Select all  Expand view

METHOD MY_ToCSV( cFile, aCols, lHeaders, cTrue, cFalse ) CLASS TXBrowse

   local cCsv    := ""
   local n, cLine, uVal, c, uBm, hFile
   local oExcel, oBook

   if aCols == nil
      aCols  := ::GetVisibleCols()
   else
      AEval( aCols, { |o,i| aCols[ i ] := ::oCol( o ) } )
   endif

   DEFAULT lHeaders := .t., cTrue := cXlTrue, cFalse := cXlFalse

   if lHeaders
      for n := 1 to Len( aCols )
         if n > 1
            cCsv  += ","
         endif
         cCsv  += '"' + StrTran( aCols[ n ]:cHeader, CRLF, " " ) + '"'
      next
   endif

   uBm      := ::BookMark
   Eval( ::bGoTop )

   REPEAT
      cLine    := ""

      for n := 1 to Len( aCols )

         c     := ""

         uVal  := aCols[ n ]:Value
         c := FW_ValToCSV( uVal, cTrue, cFalse )

         if n > 1
            cLine    += ","
         endif
         cLine    += c

      next

      if !Empty( cCsv )
         cCsv += CRLF
      endif

      cCsv    += cLine

   UNTIL Eval( ::bSkip, 1 ) == 0
   ::BookMark  := uBm

   if !Empty( cFile )
      cFile    := TrueName( cFile )
      if ( hFile := fCreate( cFile, 0 ) ) > 0
         fWrite( hFile, cCsv )
         fClose( hFile )
         cCsv  := nil
      endif
   endif

return IfNil( cFile, cCsv )

 

Re: Add a extra option to the method ToCSV

PostPosted: Thu Sep 24, 2020 2:23 am
by nageswaragunupudi
We will provide a new parameter for the delimiter in our next versions.
We will also publish a patch for you here.

You can use derived classes of xbrowse very easily.
You can use the derived class for the entire application or different derived classes for different browses.
Please see samples xbrchild.prg, xbrcalen.prg and xbrstgrd.prg in the samples folder.

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 1:46 am
by nageswaragunupudi
Implemented in FWH2009

Code: Select all  Expand view
METHOD ToCSV( cFile, aCols, lHeaders, cTrue, cFalse, cDelim ) CLASS TXBrowse

   local cCsv    := ""
   local n, cLine, uVal, c, uBm, hFile
   local oExcel, oBook

   if aCols == nil
      aCols  := ::GetVisibleCols()
   else
      AEval( aCols, { |o,i| aCols[ i ] := ::oCol( o ) } )
   endif

   DEFAULT lHeaders := .t., cTrue := cXlTrue, cFalse := cXlFalse, cDelim := ","

   if lHeaders
      for n := 1 to Len( aCols )
         if n > 1
            cCsv  += cDelim
         endif
         cCsv  += '"' + StrTran( aCols[ n ]:cHeader, CRLF, " " ) + '"'
      next
   endif

   uBm      := ::BookMark
   Eval( ::bGoTop, Self )

   REPEAT
      cLine    := ""

      for n := 1 to Len( aCols )

         c     := ""

         uVal  := aCols[ n ]:Value
         c := FW_ValToCSV( uVal, cTrue, cFalse )

         if n > 1
            cLine    += cDelim
         endif
         cLine    += c

      next

      if !Empty( cCsv )
         cCsv += CRLF
      endif

      cCsv    += cLine

   UNTIL Eval( ::bSkip, 1 ) == 0
   ::BookMark  := uBm

   if !Empty( cFile )
      cFile    := TrueName( cFile )
      if ( hFile := fCreate( cFile, 0 ) ) > 0
         fWrite( hFile, cCsv )
         fClose( hFile )
         cCsv  := nil
      endif
   endif

return IfNil( cFile, cCsv )
 

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 7:07 am
by Marc Venken
Thank you !!

I wait till the release

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 9:21 am
by nageswaragunupudi
Till then, you can confidently modify your xbrowse.prg like this and keep using it.

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 9:23 am
by Marc Venken
nageswaragunupudi wrote:Till then, you can confidently modify your xbrowse.prg like this and keep using it.


I've never done that

I have to link en recompile source I believe ?

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 4:31 pm
by Otto
Marc, You are never too old to learn something new. :D
You can link in a copy of xbrowse to your program and make the changes as Mr. Rao said.

The generosity of our masters to share the knowledge and the source code is the real freedom Fivewin gives us.
Thank you Mr. Rao.
Best regards,
Otto

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 7:20 pm
by Marc Venken
Otto wrote:Marc, You are never too old to learn something new. :D
You can link in a copy of xbrowse to your program and make the changes as Mr. Rao said.


Out of curiosity :

My files :

Build.bat

Code: Select all  Expand view

@ECHO ON
IF "%1"=="O" DEL OBJ/Q
IF "%1"=="o" DEL OBJ/Q
DEL OBJ/Q

"C:\Borland\BCC7\Bin\brc32.exe" -r TEST.RC
"C:\Borland\BCC7\Bin\make.exe" -f TEST.MAK

echo ERRORLEVEL
IF ERRORLEVEL 1 GOTO COMPILEERRORS
IF ERRORLEVEL 0 goto DONE
pause
GOTO EXIT

:COMPILEERRORS
pause
GOTO EXIT

:DONE
test.exe

:EXIT
 


test.mak

Code: Select all  Expand view

#Borland make sample, (c) FiveTech Software 2005-2009

HBDIR=c:\harbour
BCDIR=c:\borland\bcc7
FWDIR=c:\fwharb

#change these paths as needed
.path.OBJ = .\obj
.path.PRG = .\
.path.ch  = $(FWDIR)\include;$(HBDIR)\include
.path.C   = .\
.path.RC  = .\

#important: Use Uppercase for filenames extensions, in the next two rules!

PRG =      \
TEST1.PRG  

C =        \
TEST1.C    

OBJ = $(PRGS:.PRG=.\OBJ)
OBJS = $(OBJ:.\=.\obj\)

PROJECT    : TEST.EXE

#RES-file wordt door COMPRES.BAT aangemaakt
#TEST.EXE  : $(PRG:.PRG=.OBJ) $(C:.C=.OBJ) TEST.RES
TEST.EXE  : $(PRG:.PRG=.OBJ) $(C:.C=.OBJ)
   echo off
   echo $(BCDIR)\lib\c0w32.obj + > b32.bc
#  echo $(OBJS), + >> b32.bc
   echo OBJ\TEST1.OBJ, + >> b32.bc

   echo TEST.EXE, + >> b32.bc
   echo TEST.MAP, + >> b32.bc
   echo $(FWDIR)\lib\FiveH.lib $(FWDIR)\lib\FiveHC.lib $(FWDIR)\lib\libmysql.lib $(FWDIR)\lib\BARLIB32.lib + >> b32.bc
   echo $(HBDIR)\lib\hbrtl.lib + >> b32.bc
   echo $(HBDIR)\lib\hbvm.lib + >> b32.bc
   echo $(HBDIR)\lib\gtgui.lib + >> b32.bc
   echo $(HBDIR)\lib\hblang.lib + >> b32.bc
   echo $(HBDIR)\lib\hbmacro.lib + >> b32.bc
   echo $(HBDIR)\lib\hbrdd.lib + >> b32.bc
   echo $(HBDIR)\lib\rddntx.lib + >> b32.bc
   echo $(HBDIR)\lib\rddcdx.lib + >> b32.bc
   echo $(HBDIR)\lib\rddfpt.lib + >> b32.bc
   echo $(HBDIR)\lib\hbsix.lib + >> b32.bc
   echo $(HBDIR)\lib\hbdebug.lib + >> b32.bc
   echo $(HBDIR)\lib\hbcommon.lib + >> b32.bc
   echo $(HBDIR)\lib\hbpp.lib + >> b32.bc
   echo $(HBDIR)\lib\hbwin.lib + >> b32.bc
   echo $(HBDIR)\lib\hbcpage.lib + >> b32.bc
   echo $(HBDIR)\lib\hbct.lib + >> b32.bc
   echo $(HBDIR)\lib\png.lib + >> b32.bc
   echo $(HBDIR)\lib\hbcplr.lib + >> b32.bc
   echo $(HBDIR)\lib\xhb.lib + >> b32.bc
   echo $(HBDIR)\lib\hbtip.lib + >> b32.bc
   echo $(HBDIR)\lib\hbzlib.lib + >> b32.bc
   echo $(HBDIR)\lib\hbmzip.lib + >> b32.bc
   echo $(HBDIR)\lib\hbziparc.lib + >> b32.bc
   echo $(HBDIR)\lib\minizip.lib + >> b32.bc
   echo $(HBDIR)\lib\hbpcre.lib + >> b32.bc

   rem Uncomment these two lines to use Advantage RDD
   rem echo $(HBDIR)\lib\rddads.lib + >> b32.bc
   rem echo $(HBDIR)\lib\Ace32.lib + >> b32.bc

   echo $(BCDIR)\lib\cw32.lib + >> b32.bc
   echo $(BCDIR)\lib\uuid.lib + >> b32.bc
   echo $(BCDIR)\lib\import32.lib + >> b32.bc
   echo $(BCDIR)\lib\ws2_32.lib + >> b32.bc
   echo $(BCDIR)\lib\wininet.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\odbc32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\nddeapi.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\iphlpapi.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\msimg32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\rasapi32.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\gdiplus.lib + >> b32.bc
   echo $(BCDIR)\lib\psdk\shell32.lib, >> b32.bc

   IF EXIST TEST.RES echo TEST.RES >> b32.bc
   $(BCDIR)\bin\ilink32 -Gn -aa -Tpe -s @b32.bc

.PRG.OBJ:
  $(HBDIR)\bin\harbour $< /N /W0 /V /Oobj\ /I$(FWDIR)\include;$(HBDIR)\include
  $(BCDIR)\bin\bcc32 -c -tWM -I$(HBDIR)\include -oobj\$& obj\$&.c

.C.OBJ:
  echo -c -tWM -D__HARBOUR__ -DHB_API_MACROS > tmp
  echo -I$(HBDIR)\include;$(FWDIR)\include >> tmp
  $(BCDIR)\bin\bcc32 -oobj\$& @tmp $&.c
  del tmp

#RES-file wordt door COMPRES.BAT aangemaakt
#TEST.RES : ..\RES\TEST.RC
#  $(BCDIR)\bin\brc32.exe -r ..\RES\TEST.RC

 


So,
1. I can take the xbrowse.prg file from source dir, change the code from mr. Rao and save this into the DIR of the application i'm working on.
2. I add in the files above (the prg = and the C = section) below test1.prg the xbrowse.prg, so the 2 prg files are linked

and that's it ? No rebuilding of lib files needed ? it can't be that easy :oops: :oops:

Re: Add a extra option to the method ToCSV

PostPosted: Wed Sep 30, 2020 7:33 pm
by Otto
Marc, yes. That is what I do.

I am sure Mr. Rao will explain it here for us.
Best regards,
Otto

Re: Add a extra option to the method ToCSV

PostPosted: Sun Oct 04, 2020 8:38 am
by nageswaragunupudi
Marc Venken wrote:Thank you !!

I wait till the release


Revised version of FWH2008 is released.
You will find this change also in this version.
Please download.

Re: Add a extra option to the method ToCSV

PostPosted: Sun Oct 04, 2020 11:29 am
by Marc Venken
Great !!! Thanks