#include once "fbgfx.bi"
#if __FB_LANG__ = "fb"
Using FB '' Keyboard scan code constants are stored in the FB namespace in lang FB
#endif
'
type TESTDATA__type
A as ulongint
B as ulongint
C as ulongint
end type
dim shared as TESTDATA__type gTestData
' ------------------------------------------------------------
sub Wait_For_ESC_or_CtrlC__Then_Return()
' Clear Inkey buffer
While Inkey <> "": Wend
Do
Sleep 25
If MultiKey(SC_ESCAPE) Then ' [ESC] key?
exit do
end if
If MultiKey(SC_CONTROL) And MultiKey(SC_C) Then ' [CTRL+C] key combination?
exit do
end if
Loop
end sub
' ------------------------------------------------------------
sub Wait_For_ESC__Then_Return()
' Clear Inkey buffer
While Inkey <> "": Wend
Do
Sleep 25
loop until inkey = chr(27) ' [ESC] key?
end sub
' ------------------------------------------------------------
Function read_testdata_file() as integer
dim as integer f
f = freefile()
open "TESTDATA.DAT" for input as #f
If Err > 0 Then
' << You folks shouldn't have a TESTDATA.DAT file, so you should be in this error handler >>
Print "Error opening TESTDATA.DAT"
Wait_For_ESC_or_CtrlC__Then_Return() '' << MultiKey() HANGS >>
'''Wait_For_ESC__Then_Return() " << InKey() WORKS >>
print "inside - after the Open ERR wait()"
close #f
return 1
end if
print "inside - after good file open()"
'
dim as string keys(1 to 3)
input #f, keys(1), _
keys(2), _
keys(3)
If Err > 0 Then
Print "Error reading TESTDATA.DAT"
Wait_For_ESC_or_CtrlC__Then_Return()
'''Wait_For_ESC__Then_Return()
print "inside - after the Read ERR wait()"
close #f
return 2
end if
print "inside - after good file read()"
'
close #f
'
gTestData.A = val(keys(1))
gTestData.B = val(keys(2))
gTestData.C = val(keys(3))
'
RETURN 0
end Function
' ============================================================
print "main - before the testdata file read()"
read_testdata_file()
print "main - after the testdata file read()"
'
end
Thanks!
CBruce
Last edited by cbruce on Apr 11, 2021 1:13, edited 1 time in total.
Thanks for the use of FileExists(), but I still have the MultiKey() question.
If you put a couple of PRINTs in, you will find that the code stub gets into the the IF ERR code, calls Wait_For_ESC_or_CtrlC__Then_Return(), and then sits there comfortably forever.
#Include "fbgfx.bi"
Using FB
Sub Wait_For_ESC_or_CtrlC__Then_Return()
Do
Sleep 25
If MultiKey(SC_ESCAPE) Then Exit Do ' [ESC] key?
If MultiKey(SC_F4) Then Exit Do
Loop
end Sub
Dim As Long counter = 0
Dim As ZString * 3 key
Do
' Clear Inkey buffer
While Inkey <> "": Wend
counter += 1
Wait_For_ESC_or_CtrlC__Then_Return
key = InKey
Print counter & "th call"
Sleep(100, 1)
Loop Until key = Chr(255, 107) ' [Alt] + [F4]
Last edited by MrSwiss on Apr 11, 2021 0:39, edited 1 time in total.
@MrSwiss, does the stub compile and run for you? Does it get the file error and get to the sub that calls MultiKey()? And does it hang the program then for you?