FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour FWH 24.09 y bOnPostEdit
Posts: 470
Joined: Fri Feb 05, 2010 11:30 AM
FWH 24.09 y bOnPostEdit
Posted: Tue Oct 22, 2024 09:55 PM

Hola amigos..

les consulto, tengo la siguiente funcionalidad en mi xbrowse:

oBrw:aCols[19]:nEditType  :=EDIT_GET

oBrw:aCols[19]:bOnPostEdit:={|oCol,xVal,nKey,f| If(nKey==VK_RETURN,MsgStop("alerta"),)}

Cuando pulso 2click sobre la columna 19 de mi browse, me aparece get de tipo memo, escribo

lo que necesito, y cuando salgo, debo grabar eso que cambié. Solo, que los fines de mostrar el problema,

que no es la función de grabación, luego de salir del get, sale el mensaje del MsgStop(), y se vuela el programa. Hurgando

en el hb_out.log dice lo siguiente:

Exception Code:C0000005 ACCESS_VIOLATION

Exception Address:004CEDE2

Que puede estar pasando con el bOnPostEdit?

Supongo que debe ser de versión, porque utilizaba una mucho más vieja y me funcionaba correctamente.

Muchas gracias!

Roberto

Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.ar
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 01:20 PM

Buenos días Roberto, ¿qué hace este comando bOnPostEdit? Nunca lo usé. ¿Puedes explicarlo?

Gracias.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 470
Joined: Fri Feb 05, 2010 11:30 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 02:31 PM

Karinha...

después de un edit de un xbrowse, al dar enter o una tecla para seguir, te permite

realizar una opción, en este caso, yo, cuando le doy enter, necesito grabar

en un par de tablas.

Por ahora lo solucioné de otra manera, en vez de usar el EDIT_GET del xbrowse, tomé

la sugerencia del amigo César Gómez que me dijo que cambiara de botón,

así que uso que cuando presiono el click derecho de mouse, mando a otro diálogo.

Distinto a lo que tenía, pero funcional que es lo importante.

Roberto

Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.ar
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 03:16 PM

Hola Rober,

si mal no recuerdo, Rao desaconsejaba usar bonpostedit, en su lugar bEditValid o ceditvalue.

Slds.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 07:29 PM
I tested here your bOnPostEdit codeblock with FWH2409 and I have no problems at all. It is running well.

This is the program I tested with fwh2409:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oDlg, oBrw, oFont

   USE WWONDERS NEW SHARED VIA "DBFCDX"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 900,500 PIXEL TRUEPIXEL ;
      FONT oFont TITLE FWVERSION

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "WWONDERS" ;
      COLUMNS "NAME", "DETAILS" ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      :nRowHeight    := 100
      WITH OBJECT :aCols[ 1 ]
         :nEditType     := EDIT_GET
         :bOnPostEdit   := {|oCol,xVal,nKey,f| If(nKey==VK_RETURN,MsgStop("alerta"),)}
      END
      WITH OBJECT :aCols[ 2 ]
         :nEditType     := EDIT_GET
         :bOnPostEdit   := {|oCol,xVal,nKey,f| If(nKey==VK_RETURN,MsgStop("alerta"),)}
      END
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
This is the result. No problems at all.


I request other users also to run this sample as it is and let us know if they face any problems.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 07:55 PM
Please never use bOnPostEdit.

This was deprecated almost 15 years back. It is still there only for backward compatibility with very very old programs.

XBrowse internally builds bOnPost edit codeblock suitable for the database used. XBrowse knows how to save changes, including locking and unlocking records.

Let us now test the same program without bOnPostEdit

This is the modified code.
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oDlg, oBrw, oFont

   USE WWONDERS NEW SHARED VIA "DBFCDX"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 900,500 PIXEL TRUEPIXEL ;
      FONT oFont TITLE FWVERSION

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "WWONDERS" ;
      COLUMNS "NAME", "DETAILS" ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      :nRowHeight    := 100
      :nEditTypes    := EDIT_GET
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
Much smaller code:

Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 12:22 PM

¡excelente! Espectacular, me gustó este comando.

Gracias, regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 470
Joined: Fri Feb 05, 2010 11:30 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 01:32 PM

Thank you very much Mr. Rao!

I didn't know this method was obsolete.

The query is, what was the recording in the MySql table in this case?

The example is from a DBF, but what if I have a query and I want to update the edited row?

Especially when it comes to a "query" that has "INNER JOIN" included...

Always so clear and so great with explanations!

Thank you so much!!

Roberto

Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.ar
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 05:06 PM
1) Are you convinced that
Code (fw): Select all Collapse
:bOnPostEdit   := {|oCol,xVal,nKey,f| If(nKey==VK_RETURN,MsgStop("alerta"),)}
is not giving error?

2) Are you using ADO, TDolphin, TMySql or FWH built-in maria/mysql lib?
FWH natively supports all of them, The same code works.

3) Modifying Joined tales is not normally a good idea, but we will handle that issue also in next example.
Using bOnPostEdit also is one alternative, but we will deal with that in the next example.

4) For now test the above example with MySql. This sample works without any changes for any of the different mysql libraries.
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oCn, oRs
   local oDlg, oBrw, oFont

   oCn   := maria_Connect( "208.91.198.197:3306,fwhdemo,gnraofwh,Bharat@1950", .t. )
   oRs   := oCn:wwonders // or oCn:RowSet/Query( "select * from wwonders" )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 900,500 PIXEL TRUEPIXEL ;
      FONT oFont TITLE FWVERSION

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "NAME", "DETAILS" ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 2
      :nRowHeight    := 100
      :nEditTypes    := EDIT_GET
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
Does this work for you?
Regards



G. N. Rao.

Hyderabad, India
Posts: 470
Joined: Fri Feb 05, 2010 11:30 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 07:00 PM

Mr Rao:

1) Yes, yes, surely something is wrong in my xbrowse development.

2) I use Dolphin, understood....

3) Ok! Thanks!

4) Ok, tested. Works perfect!

Thank you very much for giving me your help!

Roberto

Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.ar
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Mon Oct 28, 2024 07:41 AM
but what if I have a query and I want to update the edited row?
Especially when it comes to a "query" that has "INNER JOIN" included...
Do you need to edit and modify a field of a joined table?

Try this sample:
Code (fw): Select all Collapse
function EditJoin()

   local oCn, oRs, cSql

TEXT INTO cSql
SELECT C.ID, C.City, C.State, S.name AS StateName, C.Salary
 FROM customer C LEFT JOIN states S ON C.state = S.code
 WHERE C.ID < 101
ENDTEXT

   oCn   := maria_Connect( "208.91.198.197:3306,fwhdemo,gnraofwh,Bharat@1950", .t. )
   oCn:lShowErrors := .t.

   oRs   := oCn:RowSet( cSql )
   if oRs != nil

      XBROWSER oRs COLUMNS "ID","CITY","STATENAME","SALARY" FASTEDIT SETUP ( ;
         oBrw:StateName:lReadOnly := .f. , ;
         oBrw:StateName:bEditValue := { |uNew,oCol| If( uNew == nil, oRs:StateName, SetStateName( uNew, OCol ) ) } )

      oRs:Close()

   endif
   oCn:Close()

return nil

function SetStateName( cNew, oCol )

   WITH OBJECT oCol:oBrw
      WITH OBJECT :oDbf
         :oCn:Update( "states", "name", Trim( cNew ), {{ "code", :State }} )
         :ReQuery()
      END
      :Refresh()
   END

return cNew
I am thinking of making this lot more simple in the next version

Regards



G. N. Rao.

Hyderabad, India
Posts: 470
Joined: Fri Feb 05, 2010 11:30 AM
Re: FWH 24.09 y bOnPostEdit
Posted: Mon Oct 28, 2024 07:31 PM

Thanks Mr. "Genius" Rao!

Thanks!

Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.ar

Continue the discussion