Discussion:
isRowLocked()
(too old to reply)
Glenn Johansen
2008-12-03 11:59:53 UTC
Permalink
see "reprocess" in the OLH.

- glenn
Hello everyone,
I have an application running on a network, so implicit locking is a bit
of an issue with me.
I'm trying to figure out how to use isRowLocked so that I can check
(before I have the user edit fields of a row in a form) if the row is
being edited right then.
In my code, I have the line in my EditButton_onClick function
if form.rowset.isRowLocked()
msgbox("Rowset is being edited right now")
return
endif
To test, I run the application and have a workstation edit a row in the
form. Then I go to another workstation and do the same thing. I am
expecting to see the above message box, but I don't. Instead, the window
"Row is in use by another. Retrying lock..."
If it is indeed locked, then why doesn't isRowLocked() work?
TIA for your help.
Gabriel Picache
Ken Mayer [dBVIPS]
2008-12-03 13:42:53 UTC
Permalink
Hello everyone,
I have an application running on a network, so implicit locking is a bit of an issue with me.
I'm trying to figure out how to use isRowLocked so that I can check (before I have the user edit fields of a row in a form) if the row is being edited right then.
In my code, I have the line in my EditButton_onClick function
if form.rowset.isRowLocked()
msgbox("Rowset is being edited right now")
return
endif
To test, I run the application and have a workstation edit a row in the form. Then I go to another workstation and do the same thing. I am expecting to see the above message box, but I don't. Instead, the window "Row is in use by another. Retrying lock..."
If it is indeed locked, then why doesn't isRowLocked() work?
isRowLocked() is designed for the designer to use to test their code.

To see if a row can be locked:

if not form.rowset.lockRow()
msgbox( "Rowset is being edited right now")
return
endif

Or even more useful:

// check to see if we are in the runtime, and look at the
// results of lockRow() -- if we cannot obtain a lock ... OR
// if we are working on a standalone computer as a developer,
// check to see if the row is locked ...:
if ( "runtime" $ lower( version(1) ) and not form.rowset.lockRow() ) or;
form.rowset.isRowLocked()
msgbox( "Rowset is being edited right now")
return
endif

The OLH says in the last line:

"The isRowLocked( ) method only returns information about the current
instance of a rowset. When dealing with multiple instances of a row or
rowset, you'll need to attempt an explicit row lock with the lockRow( )
method."

Note the bit about "the current instance of a rowset". In a multi-user
environment, the only time this would be the "current instance" would be
on the same computer, the same instance ... two different users can
never have the same "current instance" of a rowset.

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
G Picache
2008-12-03 16:08:13 UTC
Permalink
Dear Ken, Bruce and Glenn,

Thanks for the tips. I tried the lockrow() method, and it worked like a charm. I wasn't that clear about the OLH's phrase "the current instance of a rowset". But now that Ken made it clear, it was an "Aha!" moment.

Thanks again.
G Picache
Post by Ken Mayer [dBVIPS]
isRowLocked() is designed for the designer to use to test their code.
if not form.rowset.lockRow()
msgbox( "Rowset is being edited right now")
return
endif
// check to see if we are in the runtime, and look at the
// results of lockRow() -- if we cannot obtain a lock ... OR
// if we are working on a standalone computer as a developer,
if ( "runtime" $ lower( version(1) ) and not form.rowset.lockRow() ) or;
form.rowset.isRowLocked()
msgbox( "Rowset is being edited right now")
return
endif
"The isRowLocked( ) method only returns information about the current
instance of a rowset. When dealing with multiple instances of a row or
rowset, you'll need to attempt an explicit row lock with the lockRow( )
method."
Note the bit about "the current instance of a rowset". In a multi-user
environment, the only time this would be the "current instance" would be
on the same computer, the same instance ... two different users can
never have the same "current instance" of a rowset.
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Ken Mayer [dBVIPS]
2008-12-03 23:03:02 UTC
Permalink
Post by G Picache
Dear Ken, Bruce and Glenn,
Thanks for the tips. I tried the lockrow() method, and it worked like a charm. I wasn't that clear about the OLH's phrase "the current instance of a rowset". But now that Ken made it clear, it was an "Aha!" moment.
Thanks again.
G Picache
Glad I was able to help. That one's tripped me up a couple of times
until I got it into my head. <g>

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Bruce R. Roland
2008-12-03 12:23:14 UTC
Permalink
Gabriel,
I have an application running on a network, so implicit locking is a bit of an issue with me.
I'm trying to figure out how to use isRowLocked so that I can check (before I have the user edit fields of a row in a form) if the row is being edited right then.
In my code, I have the line in my EditButton_onClick function
I don't have a lot of experience with this yet but I would like to offfer some food for thought here and maybe someone else can jump in and add to it.

Is the "Editbutton_onclick" only running the MSGBOX() code you cite below or is it also running code to put the rowset into edit mode? I ask this as it may be an issue with timing. If the ONCLICK is also used to put the row into the edit mode it which seems to be verified by the message you are getting.what it is doing based on the message you are getting you may need to check for your rowlock in a different method.

Suggest you may want to try running this code from a Canedit event/method instead which will fire before an attempt to enter the edit mode (an onclick I believe will simply run the code but a canedit I believe will look to see if your code will allow editing - dependent on what criteria you set up - before entering the edit mode). This should cause the code to look at the state of the row before attempting to enter the edit mode which would then allow you to display your message and avoid an attempt to enter (or enterEdit mode as appropriate) the edit mode according to the results.

Hope this helps.
if form.rowset.isRowLocked()
msgbox("Rowset is being edited right now")
return
endif
To test, I run the application and have a workstation edit a row in the form. Then I go to another workstation and do the same thing. I am expecting to see the above message box, but I don't. Instead, the window "Row is in use by another. Retrying lock..."
If it is indeed locked, then why doesn't isRowLocked() work?
TIA for your help.
Gabriel Picache
Loading...