Establishing the ESC state

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Post Reply
MattC
Posts: 51
Joined: Mon 16 Apr 2018, 06:17

Establishing the ESC state

Post by MattC » Wed 17 Apr 2019, 20:35

Hi.

I'm writing a routine that requires the ESC to be set to off. (*ESC OFF.) However, the routine needs to establish whether the ESC has been set to off or on before it starts so that it can set it to the previous state on exiting, whether that was off or on. Is there a way to check the ESC state?

Matt

DDRM
Administrator
Posts: 150
Joined: Mon 02 Apr 2018, 18:04

Re: Establishing the ESC state

Post by DDRM » Thu 18 Apr 2019, 08:36

Hi Matt,

I'd hoped this would be listed on this wiki page:

http://www.bbcbasic.co.uk/wiki/doku.php ... =variables

but unfortunately it wasn't. I tried extending it with this code:

Code: Select all

      FOR x%= 0 TO 1023
        *ESC ON
        n%=?x%
        *ESC OFF
        f%=?x%
        IF n%<>f% THEN
          PRINT x%.n%,f%
          *ESC ON
          n%=?x%
          PRINT n%
        ENDIF
      NEXT x%
      *ESC ON
And it looks like byte 1019 toggles between 0 (ESC ON) and 64 (ESC OFF).

Byte 384 also changes, but that's expected: the wiki says it tells you what statement you are on!

Without documentation, I don't know what that byte is doing, but judging from it being 0/64, not 0/1, it might well be a flag byte of some sort, so you'd probably need to check bit 7 specifically - the other bits may well record other settings.

Hope that's helpful and not to misleading - test with care - or better still, ask Richard directly (and report back?).

Best wishes,

D

MattC
Posts: 51
Joined: Mon 16 Apr 2018, 06:17

Re: Establishing the ESC state

Post by MattC » Fri 19 Apr 2019, 10:20

Richard's reply suggested that the 30th bit of the @flag% variable should indicate the ESC state.

To quote:
[T]he 'ESC disabled' flag is bit 30 of @flags%:

Code: Select all

       *ESC OFF
       PRINT ~@flags%
       *ESC ON
       PRINT ~@flags%
Although that may not be explicitly documented, one might guess that is
where it would be because the 'Escape pending' flag *is* documented as
being the MS bit of @flags% (the next higher bit).
This does seem to work, so hope it will help anyone else as well

Also, I would just like to thank Richard for his advice.

Matt

DDRM
Administrator
Posts: 150
Joined: Mon 02 Apr 2018, 18:04

Re: Establishing the ESC state

Post by DDRM » Sat 20 Apr 2019, 09:19

Thanks, Matt, I thought it would be in a logical place, and that is indeed a much more logical place...

:-)

D

Post Reply