WAITKEY$ not in FreeBASIC
#1
not posted in FreeBASIC forum because a PB user will know what I'm talking about.

I'm having bad success compiling and running (from tiko).

(before someone bitches - isn't helping coders only used to PB a good subject for PUMP?

One problem is the FreeBASIC "appears" not to run because console never shows. They do run from Command Prompt because console does not close at end of code. I can not find an equivalent to WAITKEY$ in FreeBASIC. The problem presents with samples from FreeBASIC and tiko too. FreeBASIC INKEY in a loop should work. Is that the answer?

GUI sample problems later.

(repeat from elsewhere- I'm not really transitioning from PB to FreeBASIC. It is a 64 bit alternative even though what I do does not need that much horsepower)

Cheers,
Reply
#2
Code:
print "This is my console app"
print

' Use Sleep or While/Wend loop to pause and contiue displaying the console window

sleep

' - or -

while inkey$ = "": wend

Another alternative if you are using tiko and always running console programs (without the Sleep or Inkey methods), you can change the Environment setting to always run your program in a command window.

File / Preferences / Environment Options / Compiler Setup / "Run compiled programs using the command window"

Use either the Sleep/Inkey -or- Command Window Setting, but not both together.
Reply
#3
From FreeBASIC Help for SLEEP: "Waits until a specified time has elapsed, or a key is pressed."

Aha, never would have looked there (PB bias).
On relection, makes sense. If no key press give clock cycles back till next time slice for this app.

Think I'll save INKEY in a loop for getting particular keys.

"File / Preferences / Environment Options / Compiler Setup / "Run compiled programs using the command window"" Good to know. Isn't it specific to tiko, not general to FreeBASIC?

big thanks
(sure I'll run into something else)

Interested in GUI too.

If can't do a "Hello World" in console, figured no chance in GUI.
Reply
#4
(23.09.2025, 03:16 PM)Dale Yarker Wrote: From FreeBASIC Help for SLEEP: "Waits until a specified time has elapsed, or a key is pressed."

Aha, never would have looked there (PB bias).
On relection, makes sense. If no key press give clock cycles back till next time slice for this app.

Think I'll save INKEY in a loop for getting particular keys.

"File / Preferences / Environment Options / Compiler Setup / "Run compiled programs using the command window"" Good to know. Isn't it specific to tiko, not general to FreeBASIC?

big thanks
(sure I'll run into something else)

Interested in GUI too.

If can't do a "Hello World" in console, figured no chance in GUI.


In addition to SLEEP, ChatGPT points to GETKEY:

Option 2: Using
Code:
GetKey
Print "Hello, World!"
Print "Press any key to exit..."
Dim k As Integer = GetKey()  ' Waits for a key and stores it in k

    GetKey reads a keypress and returns its ASCII code (or scan code for special keys).

    This is useful if you want to know which key was pressed.
--
New PowerBASIC User Community Forum:
https://pbusers.org/forum
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)