Author Topic: What is "inkey"?  (Read 1444 times)

deeR44

  • Member
  • **
  • Posts: 101
What is "inkey"?
« on: February 27, 2022, 05:37:37 PM »
If "inkey" is a procedure or a function, what does it do and how do you work it?

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: What is "inkey"?
« Reply #1 on: February 27, 2022, 06:12:29 PM »
Its a macro that calls a procedure in the masm32 library. It stops program execution until you press a key.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

deeR44

  • Member
  • **
  • Posts: 101
Re: What is "inkey"?
« Reply #2 on: March 04, 2022, 04:24:22 PM »
Hutch, is the key then available? Thank you for your reply.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: What is "inkey"?
« Reply #3 on: March 04, 2022, 05:16:42 PM »
Just have a look at the source in the library, its really simple code.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: What is "inkey"?
« Reply #4 on: March 04, 2022, 08:20:22 PM »
Just have a look at the source in the library, its really simple code.

The inkey macro calls wait_key, which is at \Masm32\m32lib\wait_key.asm

deeR44

  • Member
  • **
  • Posts: 101
Re: What is "inkey"?
« Reply #5 on: March 05, 2022, 03:52:51 PM »
I see wait_key but I still haven't found "inkey". I don't know which library it's in. There're only about fifty libraries on my C: drive.
Thank you for the info.

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: What is "inkey"?
« Reply #6 on: March 05, 2022, 06:24:59 PM »
Well, if you can't find the macro, just CALL wait_key. Does the same thing.

Vortex

  • Member
  • *****
  • Posts: 2794
Re: What is "inkey"?
« Reply #7 on: March 05, 2022, 07:13:32 PM »
Hi deeR44,

The inkey macro is defined in the file :

Code: [Select]
\masm32\macros\macros.asm
Code: [Select]
;; ------------------------------------------------------
    ;; display user defined text, default text or none if
    ;; NULL is specified and wait for a keystroke to continue
    ;; ------------------------------------------------------
    inkey MACRO user_text:VARARG
      IFDIF <user_text>,<NULL>                  ;; if user text not "NULL"
        IFNB <user_text>                        ;; if user text not blank
          print user_text                       ;; print user defined text
        ELSE                                    ;; else
          print "Press any key to continue ..." ;; print default text
        ENDIF
      ENDIF
      call wait_key
      print chr$(13,10)
    ENDM

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: What is "inkey"?
« Reply #8 on: March 05, 2022, 09:18:32 PM »
deeR44,

"inkey" is a MACRO that calls a procedure in the MASM32 library, wait_key.asm.

The "inkey" macro is in the "\masm32\macros" directory and the file the macro is in is "macros.asm".

Why is it like this ????

The macro is easier to use and it stops a console app from exiting when its finished so you can see any results before it closes.




hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Vortex

  • Member
  • *****
  • Posts: 2794
Re: What is "inkey"?
« Reply #9 on: March 06, 2022, 07:27:42 AM »
Hi Hi deeR44,

As Hutch said, the macro is easier to use. A modified version of the Microsoft example translated to Masm :

Code: [Select]
include     \masm32\include\masm32rt.inc

.code

start:

    invoke  crt_printf,\
            CTXT("Press any key to continue.",13,10)
@@:
    invoke  crt__kbhit
    test    eax,eax
    jz      @b

    invoke  crt__getch
   
    invoke  crt_printf,\
            CTXT("Key struck was %c"),eax
   
    invoke  ExitProcess,0

END start

deeR44

  • Member
  • **
  • Posts: 101
Re: What is "inkey"?
« Reply #10 on: March 06, 2022, 09:14:38 AM »
Thank all of you for the excellent help!