The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: herge on March 18, 2009, 09:45:21 AM

Title: INKEY MACRO
Post by: herge on March 18, 2009, 09:45:21 AM

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

Title: Re: INKEY MACRO
Post by: PBrennick on March 18, 2009, 10:32:19 PM
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
Title: Re: INKEY MACRO
Post by: herge on March 19, 2009, 03:30:49 AM
 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
Title: Re: INKEY MACRO
Post by: hutch-- on March 19, 2009, 08:16:04 AM
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.