News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

What is "inkey"?

Started by deeR44, February 27, 2022, 05:37:37 PM

Previous topic - Next topic

deeR44

If "inkey" is a procedure or a function, what does it do and how do you work it?

hutch--

Its a macro that calls a procedure in the masm32 library. It stops program execution until you press a key.

deeR44

Hutch, is the key then available? Thank you for your reply.

hutch--

Just have a look at the source in the library, its really simple code.

jj2007

Quote from: hutch-- on March 04, 2022, 05:16:42 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

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

Well, if you can't find the macro, just CALL wait_key. Does the same thing.
Assembly language programming should be fun. That's why I do it.

Vortex

Hi deeR44,

The inkey macro is defined in the file :

\masm32\macros\macros.asm

;; ------------------------------------------------------
    ;; 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--

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.





Vortex

Hi Hi deeR44,

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

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

Thank all of you for the excellent help!