News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

INKEY MACRO

Started by herge, March 18, 2009, 09:45:21 AM

Previous topic - Next topic

herge


Hi There:

C:\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
      push eax ;; << Note Push
      print chr$(13,10)
      pop eax ;; << Note Pop
    ENDM


If you don't have the push and pop you get 2 which
is the length of the CRLF, and explains
why the CMP don't work after you call inkey.

Regards herge

// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

PBrennick

herge,

I wrote the following in the szlen thread. Perhaps you missed it?

Quote
The inkey macro works correctly within the boundaries of what it was designed to do. The inkey function should not be expected to function in a polcat sort of way.

Use the getkey macro which calls ret_key if you expect to receive a value.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

herge

 Hi  PBrennick:

What's a polcat?

@@:   
    inkey chr$(9, 9, 9, 9, 9, "-- Hit X Key --") ; **
    getkey
    cmp AL,"x"
    jz @F
    cmp AL,"X"
    jnz @B
@@:   
    exit


Thanks.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

hutch--

herge,

There is a secret in how to use the macros supplied with MASM32, actually bother to look at the help file for the macros, thats what its there for.

"inkey" macro.    ===>> Wait for user key input

Examples.

inkey
inkey NULL
inkey "Press a key to continue ..."

etc .....

Use the "getkey" macro to obtain the key that was pressed, documented in the same help file.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php