FWH 24.09 y bOnPostEdit

FWH 24.09 y bOnPostEdit

Postby TOTOVIOTTI » Tue Oct 22, 2024 9: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.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 421
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Re: FWH 24.09 y bOnPostEdit

Postby karinha » Wed Oct 23, 2024 1: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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: FWH 24.09 y bOnPostEdit

Postby TOTOVIOTTI » Wed Oct 23, 2024 2: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.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 421
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Re: FWH 24.09 y bOnPostEdit

Postby Ariel » Wed Oct 23, 2024 3:16 pm

Hola Rober,

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

Slds.
Ariel
 
Posts: 376
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: FWH 24.09 y bOnPostEdit

Postby nageswaragunupudi » Wed Oct 23, 2024 7: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: Select all  Expand view  RUN
#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.
Image

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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 24.09 y bOnPostEdit

Postby nageswaragunupudi » Wed Oct 23, 2024 7: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: Select all  Expand view  RUN
#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:

Image
Regards

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

Re: FWH 24.09 y bOnPostEdit

Postby karinha » 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
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: FWH 24.09 y bOnPostEdit

Postby TOTOVIOTTI » Thu Oct 24, 2024 1: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.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 421
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Re: FWH 24.09 y bOnPostEdit

Postby nageswaragunupudi » Thu Oct 24, 2024 5:06 pm

1) Are you convinced that
Code: Select all  Expand view  RUN
: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: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 24.09 y bOnPostEdit

Postby TOTOVIOTTI » Thu Oct 24, 2024 7: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.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 421
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina

Re: FWH 24.09 y bOnPostEdit

Postby nageswaragunupudi » Mon Oct 28, 2024 7: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: Select all  Expand view  RUN
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

Image
Regards

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

Re: FWH 24.09 y bOnPostEdit

Postby TOTOVIOTTI » Mon Oct 28, 2024 7:31 pm

Thanks Mr. "Genius" Rao!

Thanks!
Univ@c I.S.I.
Desarrolladores de Software
http://www.elcolegioencasa.edu.ar
User avatar
TOTOVIOTTI
 
Posts: 421
Joined: Fri Feb 05, 2010 11:30 am
Location: San Francisco - Córdoba - Argentina


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 65 guests