Page 1 of 1

Establishing the ESC state

Posted: Wed 17 Apr 2019, 20:35
by MattC
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

Re: Establishing the ESC state

Posted: Thu 18 Apr 2019, 08:36
by DDRM
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

Re: Establishing the ESC state

Posted: Fri 19 Apr 2019, 10:20
by MattC
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

Re: Establishing the ESC state

Posted: Sat 20 Apr 2019, 09:19
by DDRM
Thanks, Matt, I thought it would be in a logical place, and that is indeed a much more logical place...

:-)

D