Announcement

Collapse
No announcement yet.

Screen Writes To Console?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Screen Writes To Console?

    Does anybody have a method for writing to specific positions in the console window?

    I'm trying to port a full screen DOS BASIC data entry app to PBCC, and I need to be able to write characters in certain row, column positions without disturbing the cursor.

    I've been programming in PBCC since 2.0 came out, but everything so far has been teletype-style scrolling screens. I've been hesitant to tackle this full screen app because of the lack of a good way to write to the screen. Using LOCATE/PRINT statements always hijacks the cursor which the user is trying to follow for data entry.

    I've tried some code which turns off the cursor, then uses LOCATE and print but the result is unacceptable because the cursor is so busy servicing other parts of ths display that you can't see it.

    What I wish PBCC had was something like this:

    CONSOLEPRINT (text$, coloratt, row, col)

    I suppose I could write my own function to accomplish this, if somebody would illuminate me as to where the screen buffer is located in memory.

    Thanks in advance

    Dave Pruett
    Ypsilanti, Michigan

  • #2
    I don't quite understand what you have against the builtin LOCATE, COLOR, and CURSOR commands. Any chance of an example to illustrate the problem?

    Comment


    • #3
      I saw where Eros Olmi had posted this at one time. You might give it a try.

      You would have to INCLUDE the Win32API.INC file


      Code:
       SUB FastPrint (BYVAL lRow AS LONG, BYVAL lCol AS LONG, BYVAL lColor AS LONG, BYVAL lText AS STRING)
          STATIC g_FastPrint_hOut AS DWORD
      
          '---WIN32API ConsoleOutput starts from 0
          '---Correct as needed
          lRow = lRow - 1
          lCol = lCol - 1
      
          '---STDOUT
          IF g_FastPrint_hOut = 0?? THEN
            g_FastPrint_hOut = GETSTDOUT
          END IF
      
          '---Write text
          WriteConsoleOutputCharacter g_FastPrint_hOut, BYCOPY lText, LEN(lText), MAKDWD(lCol, lRow), 0??
      
          '---Change color
          FillConsoleOutputAttribute g_FastPrint_hOut, lColor, LEN(lText), MAKDWD(lCol, lRow), 0??
      
        END SUB

      Comment


      • #4
        Example:

        Originally posted by Chris Holbrook View Post
        I don't quite understand what you have against the builtin LOCATE, COLOR, and CURSOR commands. Any chance of an example to illustrate the problem?
        Chris,

        Imagine a full screen application where in one part of the screen is a data entry field, and elsewhere on the screen are other information displays being simultaneously updated. The cursor needs to remain in the data entry field to assist the user in entering data. However, with LOCATE/PRINT as the only method for updating those other displays, the cursor has to be moved to those screen positions to update those displays, during which time cursor is not present in the text field doing it's job prompting the user.

        Dave

        Comment


        • #5
          If the refresh rate in the asynchronous display part of the screen is low then on receipt of data you can copy the active console page (screen1) to screen2, update it and copy it back to screen1 - or change the active page to screen2.

          Alternatively you could turn off the cursor and rewrite your input routine to display a dummy cursor.

          Comment


          • #6
            Save cursor location, update display, put cursor back.

            Not that I can imagine trying to use a console program to handle asynchronous updates. (Which are not really asynchronous anyway unless using an additional thread of execution. Code not shown).
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Originally posted by Michael Mattias View Post
              Which are not really asynchronous anyway unless using an additional thread of execution
              If the application is keyboard-driven (actually PBCC handles mouse and Keyboard via INKEY$), then by putting the data acquisition and display into the keyin loop, it can do the same job without using threads. But as you say, code not shown.

              Comment


              • #8
                mouse and Keyboard via INKEY$...hen by putting the data acquisition and display into the keyin loop....
                Code:
                DO 
                  Z = INKEY$
                  IF  Z =  Something then 
                       update display
                  ELSEIF Z = something else Then 
                       do something else
                  ELSEIF...
                  END IF 
                LOOP
                is not asynchronous. But as long as you are in this deep, how hard can it be to make it
                Code:
                DO 
                  Z = INKEY$
                  IF  Z =  Something then 
                       [B][COLOR="Red"]savecursorInfo[/COLOR][/B]
                       update display
                [B][COLOR="Red"]       restorecursorinfo[/COLOR][/B]
                   ELSEIF Z = something else Then 
                       do something else
                  ELSEIF...
                  END IF 
                LOOP
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  I think you would have to poll the keyboard with INSTAT, not wait for a key.

                  Comment


                  • #10
                    >I think you would have to poll the keyboard with INSTAT, not wait for a key.

                    I think they are equal, one returning true/false, the other returning a keyvalue or null, neither efficient.

                    WAITSTAT/WAITKEY$ is probably the best solution.
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment

                    Working...
                    X