Skip to content

Commit

Permalink
Update ckeyoff.rst
Browse files Browse the repository at this point in the history
A better explanation of potential bugs.
On behalf of Per Witte.
  • Loading branch information
NormanDunbar committed Feb 23, 2022
1 parent c963c68 commit b3cfde5
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions sphinx/source/C/ckeyoff.rst
Expand Up @@ -22,33 +22,38 @@ There were problems with this command prior to v1.56.

**Note 2**

At some point CKEYOFFstarted to have to take a channel number, ie
CKEYOFF #channel.
At some point CKEYOFF required a channel number parameter, ie CKEYOFF
#channel. If you don't specify a channel number the command falls back on the current
S*BASIC's channel #0.

If you dont give a
channel number the commands try to open their own channel - that hybrid
number 0/1, as do a number of IO commands (at least in SMSQ/E). All well
and good. But if you, say, open your first channel as number 3, as happens
automatically if your first channel in a daughter SBASIC or Qlib compiled
job, and you open it with ch = FOPEN("con_") then, if that channel is
OUTLiNed to be smaller than the default channel, the call fails and returns
to the routine - which gives up. But doesnt say anything! However, now
there is dangling, open channel in the main channel table that SBASIC
doesnt know about. So next time you use this command yet another channel is
opened in the main channel table! And so it goes on ad finitum until the
job is killed - or the system chokes.
Unfortunately, if there isn't already a channel #0 open, for example, a program might have opened
its first channel using:

This is a rare circumstance, admittedly, but it is still a bug.
1500 main = FOPEN("con_")

In this case, the the CKEYOFF command will open a new console
channel and then try to set the window size of that
channel to the default size of 256x62. If, however, the program had already OUTLN'ed
#main to a smaller size, in any dimension, than 256x62, then this call will fail.

The bug fix is that
if the circumstances described pertain, the call will return with an Out of
Range error.
And here's the bug: Instead of closing the failed console channel, the command
simply returns without error. This leaves a "dangling" console channel open
without an S*BASIC handle. And each repeated call to CKEYOFF/CKEYON opens
another such channel!

As of ptr_gen 2.07 and SMSQ/E 3.39, this bug should be fixed, in that an "Out of
Range" error will be returned should the situation described above arise.

The workaround for earlier versions is: Always use this command with a
channel number *unless* there is definitely an available console channel #0!


The bug fix is that, if the circumstances described pertain, the call will return with an "Out of
Range" error.



**CROSS-REFERENCE**

:ref:`ckeyon` tells the Pointer Interface to
recognise the cursor keys again.
:ref:`ckeyon` tells the Pointer Interface to recognise the cursor keys again.

0 comments on commit b3cfde5

Please sign in to comment.