News:

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

Console ReadLine

Started by lelejau, December 14, 2010, 04:00:42 PM

Previous topic - Next topic

lelejau

Hello. I searched and I didnt find anything about read line in console.

Like:

scanf("%d",&num); in c++
or

string line = Console.ReadLine(); in c#.

How do I do it in assembly?
Learning assembly :)

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

lelejau

should I use

ReadConsoleInput Function ?
Learning assembly :)

oex

Yes, it depends what you are trying to do though.... You might be better off with the masm32 'input' macro if you are coming from C#
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

that's the correct function for what you want to do   :U
it is a good exorcise to use that one, because it will familiarize you with using win32 data structures in asm
you could also use ReadConsole for one character at a time
another way to go is to open the console as a file and use ReadFile

lelejau

already got it...


    invoke crt_scanf,addr szFormat,addr buffer
    invoke crt_printf, addr szFormat, addr buffer
    call crt__getch

And yes, I'm kinda coming from C#.
Learning assembly :)

redskull

I would recommend ReadConsole(), and not ReadConsoleInput().  The latter will give any sort of event, including mouse events, focus messages, etc.  The former just gives characters from the keyboard, which is probably what you are after.

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

lelejau

Learning assembly :)

redskull

Strange women, lying in ponds, distributing swords, is no basis for a system of government