Page 1 of 1
FWH 24.09 y bOnPostEdit
Posted: Tue Oct 22, 2024 9:55 pm
by TOTOVIOTTI
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
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 1:20 pm
by karinha
Buenos días Roberto, ¿qué hace este comando bOnPostEdit? Nunca lo usé. ¿Puedes explicarlo?
Gracias.
Regards, saludos.
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 2:31 pm
by TOTOVIOTTI
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
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 3:16 pm
by Ariel
Hola Rober,
si mal no recuerdo, Rao desaconsejaba usar bonpostedit, en su lugar bEditValid o ceditvalue.
Slds.
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 7:29 pm
by nageswaragunupudi
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
#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.
Re: FWH 24.09 y bOnPostEdit
Posted: Wed Oct 23, 2024 7:55 pm
by nageswaragunupudi
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
#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:
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 12:22 pm
by karinha
¡excelente! Espectacular, me gustó este comando.
Gracias, regards, saludos.
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 1:32 pm
by TOTOVIOTTI
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
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 5:06 pm
by nageswaragunupudi
1) Are you convinced that
Code: Select all | Expand
: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
#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?
Re: FWH 24.09 y bOnPostEdit
Posted: Thu Oct 24, 2024 7:00 pm
by TOTOVIOTTI
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
Re: FWH 24.09 y bOnPostEdit
Posted: Mon Oct 28, 2024 7:41 am
by nageswaragunupudi
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
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
Re: FWH 24.09 y bOnPostEdit
Posted: Mon Oct 28, 2024 7:31 pm
by TOTOVIOTTI
Thanks Mr. "Genius" Rao!
Thanks!