Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Toggles the indicated bit and return changed value: one becomes zero; zero becomes one

 

Syntax

 

nBit = BIT_Toggle(InValue, BitNumber)

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

InValue

Numeric

No

This parameter will be casted to a QUAD data type before checking bits

BitNumber

Numeric

No

The bit in question: from 31 to 0

The first bit is the least-significant bit, which is bit number zero.

See example for more info

 

Remarks

 

Restrictions

 

See also

 

Examples

 

Uses "Console"

 

Dim l As Long

 

'---Bits representation---------------

'---   3         2         1

'---  10987654321098765432109876543210

l = &b10000000000010000000000000000001

'---MSB = bit 31           LSB = bit 0

 

PrintL "Bit  0 is "Bit(l,  0) '---Will return 1 because bit  0 (LSB) is 1

PrintL "Bit 31 is "Bit(l, 31) '---Will return 1 because bit 31 (MSB) is 1

PrintL "Bit 20 is "Bit(l, 20) '---Will return 0 because bit 20 is 0

PrintL "Bit 19 is "Bit(l, 19) '---Will return 1 because bit 19 is 1

 

PrintL

PrintL "Now changing some bits"

 

l = Bit_Reset(l, 19)

PrintL "After reset  Bit 19 is now "Bit_Get(l, 19) '---Will return 0

l = Bit_Toggle(l, 19)

PrintL "After toggle Bit 19 is now "Bit_Get(l, 19) '---Will return 1

l = Bit_Reset(l, 19)

PrintL "After reset  Bit 19 is now "Bit_Get(l, 19) '---Will return 0

l = Bit_Set(l, 19)

PrintL "After set    Bit 19 is now "Bit_Get(l, 19) '---Will return 1

 

WaitKey

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software