flat assembler
Message board for the users of flat assembler.

Index > Windows > Procedures (Sleep, Print, ClearScreen, Pause)

Author
Thread Post new topic Reply to topic
Joey



Joined: 02 Jul 2004
Posts: 4
Location: England, UK
Joey 23 Oct 2004, 20:57
I was just wondering if any body could give me procedures to do the following tasks in FASM.

Sleep <Miliseconds> (pauses program for set length of time)
ClearScreen (clears the console)
Print <Nul terminated String> (without automatically adding line end)
Pause (wait for the user to press a key)

If someone could give me a procedure to each of these and show me how to use them then it would be greatly appreciated.

Note: This is probably obvious but there in console mode.

Errmm.. Embarassed another silly question how do i make a win32 console program (.exe) and not (.com) i know i will need to use a linker i was justwondering if there is anything that needs to be anywhere or not. :S

If someone could give me a source showing the procedures and there usage in 1 file i would be thankful Smile

Thanks in advance Smile

Joey ^__^ (new to asm)
Post 23 Oct 2004, 20:57
View user's profile Send private message MSN Messenger Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx 24 Oct 2004, 02:19
Hey Joey.
Well, i have implemented some of the funcitons that you want and wraped the functions with macros for more easy to use functions. Theres you will find some bugs, but the example is fully working. The functions thats works are in the example and looks like this:

Code:
 
;********************************************************************
; CONSOLE UTILS
; GNU GENERAL PUBLIC LICENCED, BY ZONA SERVICES.
; HTTP://WWW.ZONAUY.COM - FLORIDA URUGUAY
;********************************************************************
; -----------------------------------------------------------
; PARAMS
; -----------------------------------------------------------
format PE GUI 4.0
entry MAIN
include 'conutils.inc'

; -----------------------------------------------------------
; CODE START
; -----------------------------------------------------------
section '.code' code readable executable

; -----------------------------------------------------------
; MAIN PROC
; -----------------------------------------------------------
proc MAIN
        OpenConsole ;Open the console window
        Print IntroMessage
        Input strTestInput ;Read an string
        SetColor 3
        Locate 10,10
        Print [strTestInput] ;Print the readed string
        SetColor 6
        Locate 20,20
        Print [strTestInput]
        Sleep 2000 ;Wait 3 seconds
        CloseConsole ;Close The Console
        Halt
endp
    


Thanks to the macros, you can use a basic like syntax. Im working with this because im trying to make a BASIC Style language, but fully created with macros. Smile

You need to study the conutils.inc wheres i have the macros and the functions. Theres some funcitons thats actually are'nt wrapped and the some macros thats are not working.

I hope this can help you.

Cheers.


Description:
Download
Filename: Console.zip
Filesize: 4.37 KB
Downloaded: 412 Time(s)


_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 24 Oct 2004, 02:19
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 24 Oct 2004, 04:25
Hi,
Code:
format PE CONSOLE 4.0 
    
Post 24 Oct 2004, 04:25
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx 24 Oct 2004, 07:02
Hi roticv. It's ok, im ussing PE GUI to have full control on the open console and close console. With this, you can for example have the app running on memory and show the console when you like, or dont show the console.
Smile
This is an example on how to do that:
Code:
 
;********************************************************************
; CONSOLE UTILS
; GNU GENERAL PUBLIC LICENCED, BY ZONA SERVICES.
; HTTP://WWW.ZONAUY.COM - FLORIDA URUGUAY
;********************************************************************

; -----------------------------------------------------------
; PARAMS
; -----------------------------------------------------------
format PE GUI 4.0
entry MAIN
include 'conutils.inc'


; -----------------------------------------------------------
; VARIABLES
; -----------------------------------------------------------
section '.data' data readable writable
   LPSTR strTestInput
   STRING IntroMessage,'Write your name: '
   STRING HelloMessage,'Hello '
   STRING MsgBoxTitle,'Message:'
   STRING ConsoleOpenMessage,'Now Console Opened...'
   STRING ConsoleClosedMessage,'Now Console Closed!'
   STRING ConsoleOpenedAgainMessage,'Now Console Opened Again...'
   STRING ConsoleClosedExitMessage,<'Now Console Closed Again!',13,10,"And Now I'll Exit Smile">

; -----------------------------------------------------------
; CODE START
; -----------------------------------------------------------
section '.code' code readable executable

; -----------------------------------------------------------
; MAIN PROC
; -----------------------------------------------------------
proc MAIN
        OpenConsole ;Open the console window
        Print ConsoleOpenMessage ;Print in the console
        Input strTestInput ;Wait for press enter
        CloseConsole ;Close the console
        MsgBox ConsoleClosedMessage ;Show the message box
        OpenConsole  ;Reopen a new console
        SetColor 3  ;Change the print color
        Print ConsoleOpenedAgainMessage ;Print to the console
        Input strTestInput ;Wait for enter..
        CloseConsole ;Close The Console
        MsgBox ConsoleClosedExitMessage ;Show exit message
        Halt
endp
    


Even, i have aded some extra macros to console.inc, and modified the kind of how the variables works. You can see now two asm. Console.asm and Console2.asm; this example code is in the Console2.asm. Try to compile it.

Smile

Cheers.


Description:
Download
Filename: Console.zip
Filesize: 4.4 KB
Downloaded: 360 Time(s)


_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 24 Oct 2004, 07:02
View user's profile Send private message Visit poster's website Reply with quote
metalfishx



Joined: 30 Sep 2004
Posts: 65
Location: Florida, Uruguay
metalfishx 26 Oct 2004, 00:47
Hey! heres the new version that have all you want.
With this inc you can use: Sleep, WaitKey (instead Pause), Locate, Print, Input, Inkey, SetColor, OpenConsole, CloseConsole, ConsoleTitle, MsgBox, And Halt. You can see how to use these functions in the examples, and you can study the inc code to know how i do all that Smile

Code:
;********************************************************************
; CONSOLE UTILS EXAMPLE4
; GNU GENERAL PUBLIC LICENCED, BY ZONA SERVICES.
; HTTP://WWW.ZONAUY.COM - FLORIDA URUGUAY
;********************************************************************

; -----------------------------------------------------------
; PARAMS
; -----------------------------------------------------------
format PE GUI 4.0
entry MAIN
include 'conutils.inc'

; -----------------------------------------------------------
; VARIABLES
; -----------------------------------------------------------
section '.data' data readable writable
   LPSTR strTestInput
   STRING conTitle,".::[ Console Utils Example 4 ]::."
   STRING msgWhat,"Write something:"
   STRING msgWrote,"You Write:"
   STRING message,"Press any key to continue..."
   STRING message2,"Press any key to exit.."

; -----------------------------------------------------------
; CODE START
; -----------------------------------------------------------
section '.code' code readable executable

; -----------------------------------------------------------
; MAIN PROC
; -----------------------------------------------------------
proc MAIN
     OpenConsole ;Open the console window
      ConsoleTitle conTitle
      SetColor 6
      Locate 23,2
       Print conTitle
      Sleep 2000
       Locate 26,7
      SetColor 2
       Print message ;Print Press any key to continue...
      WaitKey
       Cls
      Locate 18,10
       Print msgWhat
      Locate 35,10
       Input strTestInput
      Cls
      SetColor 4
       Print msgWrote
      Locate 10,0
       Print [strTestInput] ;In this case, the string is a pointer to string
      Locate 26,12
       Print message ;Print Press any key to continue...
      WaitKey
      Cls
      SetColor 0
       Print message2
      WaitKey
     CloseConsole ;Close The Console
       Halt
endp                                 
    

Enjoy!


Description: File with example and icnlude file. Supports:Sleep, WaitKey (instead Pause), Locate, Print, Input, Inkey, SetColor, OpenConsole, CloseConsole, ConsoleTitle, MsgBox, And Halt.
Download
Filename: Console.zip
Filesize: 6.41 KB
Downloaded: 419 Time(s)


_________________
---------------------------------------
Roberto A. Berrospe Machin
Ruta Internet, Florida Uruguay
---------------------------------------
Post 26 Oct 2004, 00:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.