I'm writing a program that uses a very large number of variables. When the program completes, it returns to the start of the program where it displays a menu of options for the user. Each time the program returns to the start, I want to issue a "Clear" command to clean up all the variables that have been in use. However, I'm having a problem with "Clear" interacting with the console in a way that I cannot explain.
NOTE: I am using QB64 1.5 64-bit on Windows 10 20H2
Take a look at this code sample:
Option _Explicit
ProgramBegin:
$Console:Only
_Source _Console
Rem $Dynamic
Width 120, 30
Option Base 1
Clear
Dim a As String
Input "Enter some text (anything is fine): "; a$
Print "You entered: "; a$
Input a$ ' This line is only here to pause program execution
GoTo ProgramBegin
If I run the above code, a window opens but I never see any text at all. In other words, the prompt for the "Input" on line 12 is never displayed. Without the "Clear" command it displays just fine.
Now, look at the following code. The only difference is that I move the "Clear" command to a few lines earlier in the program:
Option _Explicit
ProgramBegin:
Clear
$Console:Only
_Source _Console
Rem $Dynamic
Width 120, 30
Option Base 1
Dim a As String
Input "Enter some text (anything is fine): "; a$
Print "You entered: "; a$
Input a$ ' This line is only here to pause program execution
GoTo ProgramBegin
This time, when I run the program, I get the following error:
--------------------------
Unhandled Error #258
Line: 5 (in main module)
Invalid handle
Continue?
--------------------------
Note that line 5 is the one that reads "$Console:Only". So again, it seems to have some sort of negative interaction with the console. Can anyone help me to understand what may be happening here? Is it simply not possible to use the "Clear" command when a console window is used?