11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Caché</strong> <strong>ObjectScript</strong> Functions$BITFINDReturns the position of the specified bit value within a bitstring.$BITFIND(bitstring,bitvalue,position,direction)ParametersbitstringbitvaluepositiondirectionThe name of a bitstring. Can be a local variable, a process-privateglobal, or a global.The value (0 or 1) to search for within the bitstring.Optional — The bit position from which the search begins. Search isinclusive of this position.Optional — A direction flag. Available values are 1 and -1. 1 = Searchforward (left to right) from the beginning of the bitstring (or fromposition) towards the end (this is the default). -1 = Search backwardfrom the end of the bitstring (or from position) towards the beginning.Description$BITFIND(bitstring,bitvalue) returns the position of the first occurrence of the specifiedbitvalue (0 or 1) within the bitstring bitstring.$BITFIND(bitstring,bitvalue,position) returns the position of the first occurrence at or afterposition of the specified bitvalue in bitstring.If the desired bit value is not found, or if position is greater than the number of bits withinthe bitstring, the return value is 0.There is also general information on bitstring functions available.ExamplesIf bitstring = [0,0,1,1,0], then the result of $BITFIND(bitstring,1) would be 3.// Set a to [0,0,1,1,0]SET $BIT(a,1) = 0SET $BIT(a,2) = 0SET $BIT(a,3) = 1SET $BIT(a,4) = 1SET $BIT(a,5) = 0// Find first 1 bit within aWRITE !,$BITFIND(a,1)186 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!