•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileBCLR(x,y)
BSET(x,y)
BCHG(x,y)
BTST(x,y)

x, y: iexp

These functions permit the resetting, setting, negating, and testing of bits.
The bit numbers are counted starting from 0 on the 'right' and are internally
ANDed with 31, so that they are always taken as being between 0 and 31.

The function BCLR() sets the y-th bit of the numerical expression x to 0.

The function BSET() sets the y-th bit of the numerical expression x to 1.

The function BCHG() sets bit y of numerical expression x to 1 if it was 0, or
sets it to 0 if it was 1.

The function BTST() returns -1 (TRUE) if bit y of numerical expression x is
equal to 1 and 0 (FALSE) if it is equal to 0.

Examples:

    x=BSET(0,3)
    PRINTx,BSET(0,5)

--> The numbers 8 (2^3) and 32 (2^5) appear on the screen.

    REPEAT
      t|=INP(2)
      PRINT CHR$(t|),CHR$(BCLR(t|,5))
    UNTIL CHR$(t|)="x"

--> If CapsLock is off, this program prints the letter corresponding to the key
    pressed, in both lower and upper case. (With lower case letters, bit 5 is
    always set; resetting this bit forces the transformation to upper case).

    s$="TESTcase"
    FOR i%=1 TO LEN(s$)
      PRINT CHR$(BCHG(ASC(MID$(s$,i%)),5));
    NEXT i%

--> Displays testCASE on the screen. Each lower case letter is changed to upper
    case, and vice versa. (this will not work with umlauted characters).

Memo: This generates the error message 'number not a word':
      r&=-1
      r&=BCLR(r&,15)    !seems logical yet it fails
      r&=AND(r&,&H7FFF) !use this instead
      Why does it fail?  The variable is seen as a LONG regardless.