Joy Conner
6th August 2002, 23:55
I am wondering if I am interpreting functions that deal with application locks correctly.

I am interested in checking for an application lock without actually setting an application lock. For example....

lock = appl.set(application.name$(32), appl.write)

Here lock is equal to 2 when an application lock is in place.

Or lock is equal to 0 when no application lock is found. However the function call effectively has set the lock.

Is there a function that will check for an application lock without setting the lock?

Thanks in advance for your help. - Joy

~Vamsi
7th August 2002, 00:09
Is there a function that will check for an application lock without setting the lock?

I believe the answer is no. As an alternative you could read the application lock table yourself.

evesely
7th August 2002, 00:21
I don't know of a function that just does a check, but you could easily code one:

if appl.set(app.name, appl.write) = 0 then
appl.delete(app.name)
'Lock wasn't set
else
'Lock was set or error
endif

The end result should leave the lock status the same as it was before the call.

The other way would be to read ttadv998 as Vamsi suggests. Be sure to do so for company 0, since that is where the locks are stored.

NPRao
7th August 2002, 00:25
Hi Joy,

Vamsi is right and as described in the help manual, you can use this construct -


ret = appl.set( "tisfc001" & tisfc001.pdno, APPL.READ)
if ret > 0 then
|* Lock is already present, give message
endif
if ret = 0 then
appl.delete( "tisfc001" & tisfc001.pdno )
|* remove the application lock
endif


appl.delete() -
This removes a specified application lock. Only the owner of the lock can delete it. And a lock can be deleted only from within the same process in which it was set.

This might be a safe option.

I guess you can ignore my posting... I noticed that Ed posted a solution at the same time I did....

Joy Conner
7th August 2002, 15:06
Thanks for everyone's input. Basically you have confirmed my interpretation.

Just one more thing to note. The documentation that I have on appl.delete does not mention that only the owner of a lock can remove a lock.

It is helpful to know such things. - Joy

mark_h
7th August 2002, 15:39
Couldn't you use appl.get.user? It returns 0 when a lock exists and -1 when no locks exist. This would not set a lock. Did I not understand the question? Just curious since no one else mentioned it.

Mark

Joy Conner
7th August 2002, 16:45
Hi Mark. I considered appl.get.user() but according to my documentation, you must send in parameter of process ID of owner. The process ID of owner will not be known in my application. - Joy

mark_h
7th August 2002, 17:00
Using the sample posted by NPR it would be:


rc = appl.get.user("tisfc001" & tisfc001.pdno,baan.user)


But if process id is part of the string name used in the first parameter, then I could see why you could not use it. I guess I was thinking of a lock you might set - when I used it I used something like NPR posted.


Mark

~Vamsi
7th August 2002, 19:26
Mark, what would we all do without you :). These days I hardly can get in a word edgewise. So I pounced on this one and gave a real bad reply. But I also seem to have dragged Prashanth and Ed along my line of thinking :D.

mark_h
7th August 2002, 20:20
According to Joys reply I think you all were closer to a answer than me. So you did pounce correctly. :)

Mark

telgar
8th August 2002, 21:59
I have found that only the user or other super users could remove the locks. However I have had problems with people removing locks and creating headaches for me later.