News:

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

PRINT (to Console)

Started by Richard van Petrov, May 31, 2010, 04:53:15 AM

Previous topic - Next topic

Richard van Petrov

How do I print text to the console with 'PRINT'?

Also, where can I find a book or tutorial lesson for PowerBASIC programming?

hutch--

Hi Richard,

Welcome on board. It depends which compiler you have, if you have PBCC you use the STDOUT command.


StdOut "Line of text"


If you are using the PBWIN compiler you need to allocate a console and use API functions to output text to the console.

If you know what you are doing you can patch the output EXE so that it runs in console mode but you will still need to use Windows API functions to output text to the console.

Here are two functions that will write to the console in PBWIN.


' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

FUNCTION conout(ByVal pstr as ASCIIZ PTR) as DWORD

    LOCAL hOutPut  as DWORD
    LOCAL bWritten as DWORD

    hOutPut = GetStdHandle(%STD_OUTPUT_HANDLE)

    WriteFile hOutPut,ByVal pstr,len(@pstr),ByVal VarPtr(bWritten),ByVal %NULL

    FUNCTION = bWritten

END FUNCTION

' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

FUNCTION errout(ByVal pstr as ASCIIZ PTR) as DWORD

    LOCAL hOutPut  as DWORD
    LOCAL bWritten as DWORD

    hOutPut = GetStdHandle(%STD_ERROR_HANDLE)

    WriteFile hOutPut,ByVal pstr,len(@pstr),ByVal VarPtr(bWritten),ByVal %NULL

    FUNCTION = bWritten

END FUNCTION

' «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Richard van Petrov

Thank you Hutch.

I finally got it to work using 'STDOUT'.