xbrowse command not working properly -- MR. RAO

Re: xbrowse command not working properly -- MR. RAO

Postby nageswaragunupudi » Wed Feb 23, 2022 5:04 pm

Silly question , for xbrowse class, FieldGet is character or number? Same for FieldName data type??


Following DBF syntax, FileldGet method in the classes also is meant to be used with column number only.
So, if we want to get the value of a field by name, we need to write
Code: Select all  Expand view

? o:FieldGet( o:FieldPos( fieldname ) )
 


But the reduce the work of programmer, many classes and all FWH classes allow use of either field number or field name. So, with these classes
Code: Select all  Expand view

? o:FieldGet( fieldname )
 

also works.

FWH goes further.
We can even use expressions:
Code: Select all  Expand view

? o:FieldGet( "QUANTITY * PRICE" )
 

where QUANTITY and PRICE are field names.

Now, you may ask. Why did we write fieldGet( name ) in the beditvalue but not fieldget( ncol ).
At that time we were getting problem with fieldget( ncol ) with the version of TMySql we were using, but fieldget( name ) was working.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10619
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse command not working properly -- MR. RAO

Postby Compuin » Wed Feb 23, 2022 5:06 pm

nageswaragunupudi wrote:In the XBrowse.prg, Line no:7371
Code: Select all  Expand view

   DEFAULT oCol:bEditValue := { |x| If( x == nil, ::oMySql:FieldGet( cName ), ::oMySql:FieldPut( nCol, x ) ) }
 


Change this as:

Code: Select all  Expand view

if ::oMySql:IsKindOf( "TMSQUERY" )
   DEFAULT oCol:bEditValue := { |x| If( x == nil, ::oMySql:FieldGet( nCol ), ::oMySql:FieldPut( nCol, x ) ) }
else
   DEFAULT oCol:bEditValue := { |x| If( x == nil, ::oMySql:FieldGet( cName ), ::oMySql:FieldPut( nCol, x ) ) }
endif
 



Hello Mr. Rao

Same issue

Called from E1FIELDGET(0)
Called from TMSQUERY:FIELDGET(639) in source\prg\msquery.prg
Called from MXCTAALM(26) in source\Mxctaalm.prg
Called from (b)CLINICA32WIN(69) in source\Clinica32win.prg
Called from TBTNBMP:CLICK(713) in .\source\classes\BTNBMP.PRG
Called from TBTNBMP:LBUTTONUP(999) in .\source\classes\BTNBMP.PRG
Called from TCONTROL:HANDLEEVENT(1817) in .\source\classes\CONTROL.PRG
Called from TBTNBMP:HANDLEEVENT(2051) in .\source\classes\BTNBMP.PRG
Called from _FWH(3559) in .\source\classes\WINDOW.PRG
Called from WINRUN(0)
Called from TMDIFRAME:ACTIVATE(1097) in .\source\classes\WINDOW.PRG
Called from CLINICA32WIN(138) in source\Clinica32win.prg
Called from MAIN(6) in source\Clinica32.prg
------------------------------------------------------------------------


This is FieldGet method

Code: Select all  Expand view

//---------------------------------------------------------------------------//
// Devuelve el valor de la columna en formato xBase

METHOD FieldGet( nFld ) CLASS TMSQuery
return( E1FieldGet( ::hMySQL, nFld ) )
 
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: xbrowse command not working properly -- MR. RAO

Postby Compuin » Wed Feb 23, 2022 5:27 pm

Mr Rao

I did this

Code: Select all  Expand view

? oTb:FieldGet( oTb:FieldPos( "CODALM" ) )
 


And I got this

Image
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: xbrowse command not working properly -- MR. RAO

Postby nageswaragunupudi » Wed Feb 23, 2022 5:37 pm

Then
Code: Select all  Expand view
  DEFAULT oCol:bEditValue := { |x| If( x == nil, ::oMySql:FieldGet( nCol ), ::oMySql:FieldPut( nCol, x ) ) }
 

this should work. Right? Unless the value is invalid ( like 0, nil, etc )
It may help us to put a trace
Code: Select all  Expand view

? n
 

before this line.
We see the value of "nCol" when the xbrowse command is being executed
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10619
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xbrowse command not working properly -- MR. RAO

Postby Compuin » Wed Feb 23, 2022 5:45 pm

nageswaragunupudi wrote:Then
Code: Select all  Expand view
  DEFAULT oCol:bEditValue := { |x| If( x == nil, ::oMySql:FieldGet( nCol ), ::oMySql:FieldPut( nCol, x ) ) }
 

this should work. Right? Unless the value is invalid ( like 0, nil, etc )
It may help us to put a trace
Code: Select all  Expand view

? n
 

before this line.
We see the value of "nCol" when the xbrowse command is being executed


With the police

Image

And then

Application
===========
Path and name: C:\clinica32\Clinica32.exe (32 bits)
Size: 4,612,608 bytes
Compiler version: Harbour 3.2.0dev (r2104281802)
FiveWin version: FWH 20.12
C compiler version: Microsoft Visual C 19.29.30133 (32-bit)
Windows version: 10.0, Build 19043

Time from start: 0 hours 0 mins 18 secs
Error occurred at: 23/02/2022, 12:43:03
Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = A {TXBRWCOLUMN,TXBRWCOLUMN} length: 2
[ 2] = U

Stack Calls
===========
Called from: source\xbrowse.prg => TXBROWSE:COLATPOS( 4544 )
Called from: source\xbrowse.prg => (b)TXBROWSE( 709 )
Called from: source\xbrowse.prg => TXBROWSE:SELECTEDCOL( 0 )
Called from: source\xbrowse.prg => TXBROWSE:PAINT( 2181 )
Called from: source\xbrowse.prg => TXBROWSE:DISPLAY( 2126 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1793 )
Called from: source\xbrowse.prg => TXBROWSE:HANDLEEVENT( 11821 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 448 )
Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 24 )
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TMSQUERY:ERROR( 148 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 77 )
Called from: ../../../tobject.prg => TMSQUERY:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TMSQUERY:CSORT( 142 )
Called from: source\xbrowse.prg => TXBRWCOLUMN:ADJUST( 12803 )
Called from: source\xbrowse.prg => TXBROWSE:ADJUST( 1490 )
Called from: source\xbrowse.prg => TXBROWSE:INITIATE( 1334 )
Called from: source\xbrowse.prg => TXBROWSE:CREATEFROMCODE( 1176 )
Called from: source\Mxctaalm.prg => MXCTAALM( 76 )
Called from: source\Clinica32win.prg => (b)CLINICA32WIN( 69 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 713 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 999 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1817 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2051 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1097 )
Called from: source\Clinica32win.prg => CLINICA32WIN( 138 )
Called from: source\Clinica32.prg => MAIN( 6 )
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: xbrowse command not working properly -- MR. RAO

Postby Compuin » Fri Feb 25, 2022 2:33 am

Hello Mr. RAO

Any advise? Do you need something else??
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: xbrowse command not working properly -- MR. RAO

Postby Compuin » Sun May 08, 2022 2:14 pm

Hello forum,

After some time, Mr Rao has managed to include Eagle1 in Xbrowse and Datarow making it more compatible and taking full advantage of all the facilities of the class.

Thank you very much Mr. Rao and Manu Esposito for making this possible.

Code: Select all  Expand view

//#include "Eagle1.ch"
#include "FiveWin.ch"
#include "dtpicker.ch"
#include "calendar.ch"

//#define REVD

static ntmp

STATIC oQry

//----------------------------------------------------------------------------//

function Main()

   local oCn, oDlg, oFont, oBrw
   local oConnect                  // Connection object
   local oQry                      // DataSet or RecordSet object
   local cHost     := "127.0.0.1"
   local cUser     := "root"
   local cPassword := ""
   local cDbName   := "fwhdemo"
   local cTable    := "customers" //"wwonders" //"customers" //"customer"
   local cPort, oRec

   FWNumFormat( "A", .t. )
   SetGetColorFocus()

   // Create the "connection" object
   oConnect := TMSConnect():New()

   //  We connect to the server
   if !oConnect:Connect( cHost, cUser, cPassword, cDbName )
      MsgInfo( "There is no connection with the server", "Operation Canceled" )
      oConnect:Free()
      return( nil )
   endif

   oQry := TMsTable():New( oConnect, cTable )
   oQry:SetTinyAsLogical( .t. )

   // We open the table, we bring the result to our client
   if !oQry:Open()
      MsgInfo( "Cannot open table: " + cTable, "Operation Cancelled" )
      return( nil )
   endif
   
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15

   DEFINE DIALOG oDlg SIZE 750,500 PIXEL TRUEPIXEL FONT oFont ;
      TITLE oQry:ClassName()

   @ 50, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oQry COLUMNS "FIRST", "CITY", "SALARY", "AGE", "MARRIED" ;
      CELL LINES NOBORDER FOOTERS FASTEDIT AUTOSORT

   WITH OBJECT oBrw
      :nEditTypes := EDIT_GET
      //
      :bEdit   := { |oRec| CtrDatos( oRec ) }
      //
      :Salary:nFooterType  := AGGR_SUM
      :Age:nFooterType     := AGGR_AVG
      :MakeTotals()
      //
      :CreateFromCode()
   END

   @ 10, 10 BUTTON "&Add" SIZE 80, 30 PIXEL OF oDlg;
            ACTION oBrw:EditSource( .t. )
   @ 10, 100 BUTTON "&Mod" SIZE 80, 30 PIXEL OF oDlg;
            ACTION oBrw:EditSource()
   @ 10, 190 BUTTON "&Del" SIZE 80, 30 PIXEL OF oDlg;
            ACTION oBrw:Delete( .t. )  

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oQry:Close()
   oConnect:Close()

return nil

static procedure CtrDatos( oRec )

   local lNew  := ( oRec:RecNo == 0 )
   local oDlg

   DEFINE DIALOG oDlg FROM 2, 2 TO 30, 77;
        TITLE "Mantenimiento de la tabla Test - " + If( lNew, "ADD", "EDIT" );
        STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, 4 )

        @ 01, 02 SAY "First"        OF oDlg
        @ 02, 1.5 GET oRec:First     PICTURE "@K" UPDATE OF oDlg

        @ 01, 26.6 SAY "Last"         OF oDlg
        @ 02, 20 GET oRec:Last       PICTURE "@K" UPDATE OF oDlg

        @ 2.8, 02 SAY "Street"      OF oDlg
        @ 4, 1.5 GET oRec:Street     PICTURE "@K" UPDATE OF oDlg

        @ 2.8, 26.6 SAY "City"        OF oDlg
        @ 4, 20 GET oRec:City       PICTURE "@K" UPDATE OF oDlg

        @ 4.6, 02 SAY "State"       OF oDlg
        @ 6, 1.5 GET oRec:State      PICTURE "@K XX" UPDATE OF oDlg

        @ 4.6, 5.5 SAY "Zip"         OF oDlg
        @ 6, 4 GET oRec:Zip        PICTURE "@K 99999-9999" UPDATE OF oDlg

        @ 4.6, 13.9 SAY "Hiredate"    OF oDlg
        @ 78, 83 DTPICKER oRec:Hiredate UPDATE  PIXEL SIZE 50, 11 OF oDlg
        @ 6, 10 GET oRec:Hiredate   PICTURE "@K" UPDATE OF oDlg

        @ 5.7, 22 CHECKBOX oRec:Married PROMPT "Married"  UPDATE OF oDlg

        @ 4.6, 33 SAY "Age"         OF oDlg
        @ 6, 24.5 GET oRec:Age PICTURE "@K 999"        UPDATE OF oDlg

        @ 4.6, 37.5 SAY "Salary"      OF oDlg
        @ 6, 28 GET oRec:Salary  PICTURE "@KE 9,999,999.999"   UPDATE OF oDlg

//..................... El campo MEMO...............................................
        @ 6.4, 02 SAY "Notes"       OF oDlg
        @ 8.1, 1.5 GET oRec:Notes      MEMO         UPDATE OF oDlg SIZE 270, 65
//..................................................................................

        @ 10.5, 02 BUTTON "&Save";
                 OF oDlg;
                 SIZE 40, 12;
                 WHEN oRec:Modified() ;
                 ACTION ( oRec:Save(), oDlg:Update() )

        @ 10.5, 10 BUTTON "&Cancel";
                 OF oDlg;
                 SIZE 40, 12;
                 ACTION ( oRec:Undo(), oDlg:Update() )

        @ 10.5, 18 BUTTON "&Exit";
                 OF oDlg;
                 SIZE 40, 12;
                 ACTION oDlg:End()

    ACTIVATE DIALOG oDlg CENTERED

return

//----------------------------------------------------------------------------//

static procedure FuncVale( lNew )

    local nRec

    if lNew
        oQry:Insert( .t. )
        oQry:GoBottom()
    else
        nRec := oQry:RecNo()
        oQry:Update( .t. )
        oQry:GoTo( nRec )
    endif

return

//----------------------------------------------------------------------------//

static procedure Borrar( oBrw )

    local nRecNo := oQry:RecNo()

    if MsgYesNo( "Realmente quiere borrar el registro " + Str( oQry:RecNo() ) + "?" )
        if oQry:Delete( , 1 )
            MsgInfo( "Borrado en el servidor" )
            if MsgYesNo( "Refresca la lista?" )
                oQry:Refresh()
                oQry:GoTo( nRecNo )
                oBrw:Refresh()
            endif
        endif
    else
        MsgInfo( "No se ha borrado..." )
    endif

return

func strnum( n )
return Ltrim( str( n ) )
 


Image

Image

Image
FWH 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests