Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - barrset() set a bit array element http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 barrset()           Set a bit array element
------------------------------------------------------------------------------
 Declaration
   bit.hdr

 Syntax
   proc barrset extern
   param value _BITARRAY nArrayHandle, ;
         value ulong     nElement, ;
         value logical   lSet

 Arguments
   nArrayHandle is a bit array handle.

   nElement is the index of the element to change. Bit arrays are 0-based.

   lSet is a flag to indicate if the bit will be set.

 Return
   None.

 Description
   The barrset() procedure sets or resets an element in a bit array.

 Example
   #define EXAMPLE_MATH
   #include example.hdr

   proc Test_barrset
   vardef
      _BITARRAY pArr
      uint      n
   enddef
   pArr := barrinit( 1000, .f. )     // allocate bit array
   for n := 871 to 881               // show a range of bits
      ? n, barrget( pArr, n )
   next
   ?
   for n := 871 to 881 step 2        // set every second bit
      barrset( pArr, n, .t. )
   next
   for n := 871 to 881               // show a range of bits
      ? n, barrget( pArr, n )
   next
   barrclear( pArr )                 // free array
   endproc

   proc main
   Test_barrset()
   endproc

See Also: barrfill() barrget()

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