main logo
Subject: BizObj SeekPKValue() and MovePointer()
Author: Bhavbhuti Nathwani
Posted: 2002/02/25 23:27:44
 
View Entire Thread
New Search


I have tried on a simple form the movement of records using SeekPKValue() and a custom method in iBizObj > MovePointer() (see below).

Now what happens is that, when the movement of the record is done using MovePointer() and after the record is displayed on the form, then I exit the form by pressing Ctrl+F4, the form exits normally.

Now I changed the code to call SeekPKValue() instead of MovePointer() and I repeat the above steps, at the time of exit the form asks me if I want to save the record before exiting.

What is MovePointer() doing more right than SeekPKValue()??? I have tried putting a borwse window to check for record pointer, the movement is same for both the functions usage.

Also could somebody suggest a best practice for the code between "*v* BYN" comments. I guess it is a UI code here in a BO.


MovePointer()<code>
*---------------- Location Section ---------------------
*} Library: iBizness.VCX
*} Class: iBizObj
*} Method: MovePointer()
*-------------------------------------------------------
*) Description: Moves the record pointer in the current data recordset.
*-------------------------------------------------------
LPARAMETERS tnID, tcID

IF PCOUNT() < 2
tcID = "IID"
ENDIF

IF EMPTY(tnID)
RETURN FILE_CANCEL
ENDIF

IF !THIS.BeforePointerMove()
RETURN FILE_CANCEL
ENDIF

LOCAL lnSelect, lnRetVal
lnSelect = SELECT(0)

IF !EMPTY(THIS.cAlias) AND USED(THIS.cAlias)
SELECT (THIS.cAlias)
ENDIF

IF EMPTY(tcID)
tcID = "IID"
ENDIF

gnFieldcount = AFIELDS(gaMyArray) && Create array
gnPos = ASCAN(gaMyArray, UPPER(tcID)) && Search in array "CID"
IF gnPos = 0
RETURN FILE_CANCEL
ENDIF

* The behavior object handles the record pointer movement.

lcOldID = &tcID.
LOCATE FOR &tcID. = tnID
IF FOUND()
lnRetVal = FILE_OK
ELSE
LOCATE FOR &tcID. = lcOldID
lnRetVal = FILE_CANCEL
ENDIF


*v* Commented at 13:15:41 on February 22, 2002
IF TYPE("THISFORM.oToolbar.Name") == "C"
LOCAL lnSaveRec, lcCondition

lnSaveRec = RECNO()

SKIP
IF EOF()
THISFORM.lEOF = .T.
ELSE
THISFORM.lEOF = .F.
ENDIF

GO (lnSaveRec)

SKIP -1
IF BOF()
THISFORM.lBOF = .T.
ELSE
THISFORM.lBOF = .F.
ENDIF

GO (lnSaveRec)

THISFORM.RefreshToolBar()
ENDIF
*v* End Commenting 13:15:41 - February 22, 2002


IF lnRetVal = FILE_OK
* Tell each child bizobj (if any) to requery themselves to reflect the new parent record.
THIS.RequeryAllChildren()
THIS.SetMemento()
THIS.AfterPointerMove(lnRetVal)
ENDIF

* Restore the work area
SELECT (lnSelect)

RETURN lnRetVal</code>
Regards
Bhavbhuti
 
©2002 Bhavbhuti Nathwani
<-- Prior Message New Search Next Message -->