Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- NetLib for Clipper, Version 6.0 - n_slock( <nmaxnum>, <nmaxlen> ) --or-- n_slock( <csemaphore> ) http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
N_SLOCK( <nMaxNum>, <nMaxLen> ) --or-- N_SLOCK( <cSemaphore> )


Parameters


<nMaxNum>
Maximum number of semaphores per station. By default, the maximum
number is ten.

<nMaxLen>
Maximum length of a semaphore string. By default, the maximum length
is 60 characters.

<cSemaphore>
Semaphore string. Embedded nulls are not allowed, but any other
printable or unprintable data is acceptable. Case (lower or upper) is 
ignored. If the length of the semaphore string passed exceeds the
maximum, additional data will be truncated.


Returns

Logical true if successful (now locked at current station). If a 
station issues N_SLOCK() on a semaphore it already has locked, there is 
no effect and .T. is returned. N_SLOCK() always returns .T. if the 
program is running in single user mode (that is, when N_READY() returns 
false).

False if the semaphore cannot be locked. Common reasons for failure are 
that another station has already locked the semaphore or the current 
station has reached maximum number of semaphore locks.


Description

N_SLOCK() has two forms. The first, N_SLOCK(<nMaxNum>, <nMaxLen>),
enables you to change the maximum number of semaphores that can
be active from the default ten and the maximum length of a semaphore
string from the default 60 characters. If you choose to change these
defaults, your application must call N_SLOCK(<nMaxNum>, <nMaxLen>)
before it issues the first semaphore lock.

The second form, N_SLOCK( <cSemaphore> ), locks a semaphore. If the
current station already has the maximum number of semaphore locks, the
function will return .F. even if no other station has locked the semaphore.
In this case you will need to release (unlock) an existing semaphore before
locking a new one.

To unlock a semaphore, call N_SUNLOCK(). To determine the number of active
semaphores, call N_ISSLOCK().


Example

// Make sure only one station at a time
// can examine and update MEM file
DO WHILE ! N_SLOCK('Serial.mem')
ENDDO
RESTORE FROM serial ADDITIVE
m_serial = m_serial + 1
SAVE TO serial ALL LIKE m_serial
N_SUNLOCK('serial.mem')



See Also: N_CHECKS() N_ISSLOCK() N_SUNLOCK()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson