Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Novlib 3.30 Online Reference - <b> semvaluedecrement()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 SemValueDecrement()
------------------------------------------------------------------------------
 Purpose:
 Decrement a semaphore value by 1.

 Syntax:
 bResult = SemValueDecrement( dwSemID, wTimeOut )

 Parameters:
 dwSemID  The semaphore ID number.
 wTimeOut The timeout period in seconds.

 Returns:
 A boolean value (TRUE or FALSE).

 The CA-Clipper name for this function is:
 SemValDec()

 Description:
 SemValueDecrement() returns TRUE if the value of the semaphore specified
 by ID number dwSemID is decremented successfully.

 Returns FALSE if not, or if an error occurs.

 The timeout parameter wTimeOut causes SemValueDecrement() to wait on an
 unavailable semaphore for wTimeOut seconds. If the semaphore becomes free
 within that time SemValueDecrement() will return TRUE. Otherwise it will
 timeout and return FALSE.

 Semaphore values may be in the range -127 to 127. Attempts to decrement a
 semaphore value below 0 result in SemValueDecrement() waiting the timeout
 period wTimeOut before returning FALSE. In the meantime, if another user
 has incremented the semaphore, SemValueDecrement() will then decrement the
 semaphore and return TRUE.

 Example:
 // To open a semaphore called "UPDATE_SEM" with an initial value 24 and
 // decrement its value by one with a maximum wait of 15 seconds:
 dwSemID = SemOpen( "UPDATE_SEM", 24 )
 if ( NWErrorGet() = 0 )
    if ( SemValueDecrement( dwSemID, 15 ) )
       ? "Semaphore decremented successfully"
    endif
 endif

 Notes:
 If FALSE is returned, check NWErrorGet().

 Note for CA-Clipper:
 IMPORTANT - both positive and negative values are valid semaphore handles,
 except the value NOVERRLONG. Valid semaphore handles can be in the range
 -2147483647 to +2147483647.

See Also: SemValueIncrement() SemValueGet()

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