Getnbits() – Teledyne LeCroy CATC Scripting Language Reference Manual User Manual

Page 38

Advertising
background image

C

HAPTER

11

Primitives

CATC Scripting Language

34


A space will insert a space before a positive signed integer. This only works with the

conversion characters

d

and

i

. If both a space and a plus sign are used, the space flag

will be ignored.

A hash mark (

#

) will prepend a

0

to an octal number when used with the conversion

character

o

. If

#

is used with

x

or

X

, it will prepend

0x

or

0X

to a hexadecimal

number.

A zero (

0

) will pad the field with zeros instead of with spaces.

Field width specification is a positive integer that defines the field width, in spaces, of the

converted argument. If the number of characters in the argument is smaller than the field
width, then the field is padded with spaces. If the argument has more characters than the
field width has spaces, then the field will expand to accommodate the argument.

GetNBits()

GetNBits (<bit_source list or raw>, <bit_offset
integer>, <bit_count integer>)

Parameter

Meaning

Default Value Comments

bit_source list, raw, or

integer

bit_offset integer

Index of bit to

start reading

from

bit_count integer

Number of

bits to read

Can be an integer value (4 bytes) or a list of inte-
gers that are interpreted as bytes.

Return value

None.

Comments

Reads bit_count bits from bit_source starting at bit_offset. Will
return null if bit_offset + bit_count exceeds the number of bits in
bit_source

. If bit_count is 32 or less, the result will be returned as an

integer. Otherwise, the result will be returned in a list format that is the same as the
input format. GetNBits also sets up the bit data source and global bit offset used
by NextNBits and PeekNBits. Note that bits are indexed starting at bit 0.

Example

raw = 'F0F0';

# 1111000011110000 binary

result = GetNBits ( raw, 2, 4 );
Trace ( "result = ", result );

The output would be

Advertising