Poke 1
Poke 1
{{PageSyntax}}
:: POKE ''segment_offset'', ''offset_value''
:''Example 1:'' Turning keyboard Lock and Insert modes on and off.
{{CodeStart}} '' ''
DEF SEG = 0
oldsetting% = PEEK(1047)
POKE 1047,PEEK(1047) OR 16 ' ENABLES SCROLL LOCK
POKE 1047,PEEK(1047) OR 32 ' ENABLES NUMBER LOCK
POKE 1047,PEEK(1047) OR 64 ' ENABLES CAPS LOCK
POKE 1047,PEEK(1047) OR 128 ' ENABLES INSERT MODE
DEF SEG
{{CodeEnd}}
:''Note: Use [[XOR]] instead of [[OR]] above to alternate between on and off
modes.''
{{CodeStart}} '' ''
{{Cl|DEF SEG}} = 0
oldsetting% = {{Cl|PEEK}}(1047)
POKE 1047,PEEK(1047) AND 239 ' TURNS OFF SCROLL LOCK (239 = 255 - 16)
POKE 1047,PEEK(1047) AND 223 ' TURNS OFF NUMBER LOCK (223 = 255 - 32)
POKE 1047,PEEK(1047) AND 191 ' TURNS OFF CAPS LOCK (191 = 255 - 64)
POKE 1047,PEEK(1047) AND 127 ' TURNS OFF INSERT MODE (127 = 255 - 128)
{{Cl|DEF SEG}} '' ''
{{CodeEnd}}
:''Note: Using [[AND]] requires that the bit value is subtracted from 255 to turn
off a bit.'' The above examples won't work in NT.
:'''Warning: The keyboard lights may NOT change so it is a good idea to restore the
original settings!'''
''See also:''
* [[DEF SEG]], [[DEF SEG = 0]] {{text|(reference)}}
* [[PEEK]] {{text|(read memory)}}, [[OUT]] {{text|(write to register)}}
* [[VARSEG]], [[VARPTR]]
* [[_MEMGET (function)]], [[_MEMPUT]]
* [[Scancodes]] {{text|(demo)}}, [[Screen Memory]]
* [[PEEK and POKE Library]]
{{PageNavigation}}