Automatic record locking for aliased DCGETs
Posted: Mon Jan 24, 2011 11:42 am
Hi Roger,
I finally updated my eXpress from version 240 to 254 (I know, I am a bad boy...). There is one quite major issue with the 'Added automatic record-locking when creating a DCGET that is aliased into a database' feature which was added. Problem is, that all my edit screens (and I am talking about hundreds and hundreds of them) are using the following syntax (simplified):
LOCAL aFields := {}
IF ( cAlias )->( LOCKREC() )
aFields := ( cAlias )->( SCATTER() )
...
@ nRow, nCol XDCGET aFields[ ( cAlias )->( FIELDPOS( "FIELDNAME" ) ) ]
...
( cAlias )->( UNLOCKREC() )
ENDIF
Well, as you can see, the DCGET line has the file alias, but not in the form you expect it in your program, e.g. ( cAlias )->FIELDNAME - and this now triggers the error on each field.
Roger, would it be possible to add a GET-SET function to _dcgetbx.prg, so I do not have to remember to change this program each time I get the future eXpress update? Function can default to .T. (perform auto-lock), so no other user will be affected.
Below is my suggested GETSETFUNCTION and 4 spots (2 functions) in the _dcgetbx.prg you have to adjust:
_dcgetbx.prg
GETSETFUNCTION DC_AutoLockEditedRecord DEFAULT .T.
in FUNCTION DC_GetAnchorCB()
around line 6963
CASE DC_AutoLockEditedRecord() .AND. ;
'->' $ cVarName .AND. !Upper(Left(cVarName,3)) == 'M->' .AND. ;
!Upper(Left(cVarName,8)) == 'MEMVAR->' .AND. ;
!Upper(Left(cVarName,7)) == 'FIELD->'
...
in FUNCTION DC_GetValidate()
around line 8267
IF lLocked := DC_AutoLockEditedRecord() .AND. ;
(oXbp:isDerivedFrom('DC_XbpGet') .AND. !Empty(oXbp:dataAlias) .AND. ;
!((oXbp:dataAlias)->(RecNo()) $ (oXbp:dataAlias)->(dbRLockList())))
(oXbp:dataAlias)->(dbRLock())
ENDIF
around line 8371
IF lLocked := DC_AutoLockEditedRecord() .AND. ;
(oXbp:isDerivedFrom('DC_XbpGet') .AND. !Empty(oXbp:dataAlias) .AND. ;
!((oXbp:dataAlias)->(RecNo()) $ (oXbp:dataAlias)->(dbRLockList())))
(oXbp:dataAlias)->(dbRLock())
ENDIF
around line 8381
IF lLocked := DC_AutoLockEditedRecord() .AND. ;
(oXbp:isDerivedFrom('DC_XbpGet') .AND. !Empty(oXbp:dataAlias) .AND. ;
!((oXbp:dataAlias)->(RecNo()) $ (oXbp:dataAlias)->(dbRLockList())))
(oXbp:dataAlias)->(dbRLock())
ENDIF
I finally updated my eXpress from version 240 to 254 (I know, I am a bad boy...). There is one quite major issue with the 'Added automatic record-locking when creating a DCGET that is aliased into a database' feature which was added. Problem is, that all my edit screens (and I am talking about hundreds and hundreds of them) are using the following syntax (simplified):
LOCAL aFields := {}
IF ( cAlias )->( LOCKREC() )
aFields := ( cAlias )->( SCATTER() )
...
@ nRow, nCol XDCGET aFields[ ( cAlias )->( FIELDPOS( "FIELDNAME" ) ) ]
...
( cAlias )->( UNLOCKREC() )
ENDIF
Well, as you can see, the DCGET line has the file alias, but not in the form you expect it in your program, e.g. ( cAlias )->FIELDNAME - and this now triggers the error on each field.
Roger, would it be possible to add a GET-SET function to _dcgetbx.prg, so I do not have to remember to change this program each time I get the future eXpress update? Function can default to .T. (perform auto-lock), so no other user will be affected.
Below is my suggested GETSETFUNCTION and 4 spots (2 functions) in the _dcgetbx.prg you have to adjust:
_dcgetbx.prg
GETSETFUNCTION DC_AutoLockEditedRecord DEFAULT .T.
in FUNCTION DC_GetAnchorCB()
around line 6963
CASE DC_AutoLockEditedRecord() .AND. ;
'->' $ cVarName .AND. !Upper(Left(cVarName,3)) == 'M->' .AND. ;
!Upper(Left(cVarName,8)) == 'MEMVAR->' .AND. ;
!Upper(Left(cVarName,7)) == 'FIELD->'
...
in FUNCTION DC_GetValidate()
around line 8267
IF lLocked := DC_AutoLockEditedRecord() .AND. ;
(oXbp:isDerivedFrom('DC_XbpGet') .AND. !Empty(oXbp:dataAlias) .AND. ;
!((oXbp:dataAlias)->(RecNo()) $ (oXbp:dataAlias)->(dbRLockList())))
(oXbp:dataAlias)->(dbRLock())
ENDIF
around line 8371
IF lLocked := DC_AutoLockEditedRecord() .AND. ;
(oXbp:isDerivedFrom('DC_XbpGet') .AND. !Empty(oXbp:dataAlias) .AND. ;
!((oXbp:dataAlias)->(RecNo()) $ (oXbp:dataAlias)->(dbRLockList())))
(oXbp:dataAlias)->(dbRLock())
ENDIF
around line 8381
IF lLocked := DC_AutoLockEditedRecord() .AND. ;
(oXbp:isDerivedFrom('DC_XbpGet') .AND. !Empty(oXbp:dataAlias) .AND. ;
!((oXbp:dataAlias)->(RecNo()) $ (oXbp:dataAlias)->(dbRLockList())))
(oXbp:dataAlias)->(dbRLock())
ENDIF