Announcement

Collapse
No announcement yet.

print command

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

  • print command

    I am making the move from DOS to Windows. I spend a great
    amount of my time converting text file output from a mainframe
    to databases. I use the PRINT command as a debugging tool in my
    DOS programs. Is there a similar way to do this in
    PB for Windows? I just want to be able to display the file
    as I read it in.

    Thanks
    Jerry


    ------------------

  • #2
    jerry,

    i use the sub from: http://www.powerbasic.com/support/pb...ad.php?t=23443

    it shows a neat way to dump text [ in realtime ]to notepad....

    this code was written by david gwillim in july 2002, called "notepad logging".

    or, you can use msgbox to show small/big chunks of data....

    thanks,
    p.

    ------------------

    Comment


    • #3
      Jerry,

      I mostly use MSGBOX to display test data. But that can be a problem since
      MSGBOX will pause the program until you click OK each time. (which is
      often a good thing durring testing) However, sometimes it is nice to
      be able to watch the data scroll across the screen.

      If you have PBCC, the PRINT command is still there. But on PB for Windows
      you have to make a function to do this.

      You can include this DosPrt function in your code and then use DosPrt instead
      of the PRINT command.

      Example:
      Code:
      #DIM ALL
      #COMPILE EXE
      #INCLUDE "win32api.inc"
      '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
      FUNCTION DosPrt(sText AS STRING) AS LONG     'print to a dos window
         STATIC hCon AS LONG
         STATIC isConsole AS LONG
         LOCAL iNumDone AS LONG
         IF hCon = 0 THEN hCon = GetStdHandle(-11&)                'try to get console handle first incase this is a console app
         IF hCon = 0 THEN isConsole = 1:AllocConsole: hCon = GetStdHandle(-11&)  'if not create one first (used to test run program from the IDE)
         WriteConsole hCon, BYCOPY sText + $CRLF, LEN(sText) + 2, iNumDone, BYVAL 0&
         FUNCTION = isConsole
      END FUNCTION
      '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
      FUNCTION PBMAIN
         LOCAL sMyText  AS STRING
         sMyText = "and now for the end....."
         DosPrt "This is a test"
         DosPrt "This is line 2"
         DosPrt sMyText
      
         MSGBOX "Done"
      END FUNCTION
      '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
      The only problem with this method, is that when the program ends, the
      console window will disappear too. So you will want to add a pause to
      the end of your program. (with something like MSGBOX)

      ------------------
      "I haven't lost my mind... its backed up on tape... I think??"

      [This message has been edited by William Burns (edited March 17, 2003).]
      "I haven't lost my mind... its backed up on tape... I think??" :D

      Comment


      • #4
        some time ago i post this one. maybe it can help. http://www.powerbasic.com/support/pb...ad.php?t=23383

        ------------------
        eros olmi
        mailto:[email protected][email protected]</a>
        thinBasic programming language
        Win10 64bit - 8GB Ram - i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

        Comment


        • #5
          This works for me:
          Code:
          'set this up when establishing the Dialog
          
           l$ = "Changing Label"
                  Control Add Label, Hdlg, %Id_Changing_Label, l$, 
                       Column, Row, _
                       Length_Of_Label,  Height_of_Label, _
                       %SS_Center, _ 'center it
                       0
          
          ' Then set your data to l$ when reading it
             l$ = Data_From_File$ 
                Control Set Text Hdlg, %Id_Changing_Label, l$
          
          'You probably would want some sort of hestitation routine here
          ------------------
          Thx............Gösta
          mailto:[email protected][email protected]</A>
          http://www.SwedesDock.com
          http://www.PondersBible.com

          [This message has been edited by Gösta H. Lovgren-2 (edited March 17, 2003).]
          It's a pretty day. I hope you enjoy it.

          Gösta

          JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
          LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

          Comment


          • #6
            William - tried the DosPrt, works great from within the IDE but
            it doesn't seem to work once compiled and run from a command line
            or windows screen. Any suggestions?
            Jerry

            Originally posted by William Burns:
            Jerry,

            I mostly use MSGBOX to display test data. But that can be a problem since
            MSGBOX will pause the program until you click OK each time. (which is
            often a good thing durring testing) However, sometimes it is nice to
            be able to watch the data scroll across the screen.

            If you have PBCC, the PRINT command is still there. But on PB for Windows
            you have to make a function to do this.

            You can include this DosPrt function in your code and then use DosPrt instead
            of the PRINT command.

            Example:
            Code:
            #DIM ALL
            #COMPILE EXE
            #INCLUDE "win32api.inc"
            '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
            FUNCTION DosPrt(sText AS STRING) AS LONG     'print to a dos window
               STATIC hCon AS LONG
               STATIC isConsole AS LONG
               LOCAL iNumDone AS LONG
               IF hCon = 0 THEN hCon = GetStdHandle(-11&)                'try to get console handle first incase this is a console app
               IF hCon = 0 THEN isConsole = 1:AllocConsole: hCon = GetStdHandle(-11&)  'if not create one first (used to test run program from the IDE)
               WriteConsole hCon, BYCOPY sText + $CRLF, LEN(sText) + 2, iNumDone, BYVAL 0&
               FUNCTION = isConsole
            END FUNCTION
            '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
            FUNCTION PBMAIN
               LOCAL sMyText  AS STRING
               sMyText = "and now for the end....."
               DosPrt "This is a test"
               DosPrt "This is line 2"
               DosPrt sMyText
            
               MSGBOX "Done"
            END FUNCTION
            '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
            The only problem with this method, is that when the program ends, the
            console window will disappear too. So you will want to add a pause to
            the end of your program. (with something like MSGBOX)



            ------------------

            Comment


            • #7
              Put to text file with TRACE NEW/ON/PRINT...

              Coolest thing is you just change from...
              Code:
              #TOOLS ON
              ..to..
              Code:
              #TOOLS OFF
              .. re-compile, it and the trace is disabled...

              MCM

              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Jerry,

                That is my fault, I gave you my version I use when I change byte 221 of my compiled
                exe to a CHR$(3). (this tells windows that this is a console app)

                The version you will want will allways create a new console window:
                Code:
                #COMPILE EXE
                #INCLUDE "win32api.inc"
                '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
                SUB DosPrt(sText AS STRING)     'print to a dos window
                   STATIC hCon AS LONG
                   LOCAL iNumDone AS LONG
                   IF hCon = 0 THEN
                      AllocConsole      'create one first
                      hCon = GetStdHandle(-11&)
                   END IF
                   WriteConsole hCon, BYCOPY sText + $CRLF, LEN(sText) + 2, iNumDone, BYVAL 0&
                END SUB
                '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
                FUNCTION PBMAIN
                   LOCAL sMyText  AS STRING
                   sMyText = "and now for the end....."
                
                   DosPrt "This is a test"
                   DosPrt "This is line 2"
                   DosPrt sMyText
                
                   MSGBOX "Done"
                END FUNCTION
                '=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
                Sorry about that.

                ------------------
                "I haven't lost my mind... its backed up on tape... I think??"
                "I haven't lost my mind... its backed up on tape... I think??" :D

                Comment


                • #9
                  For extended testing (not just quick and dirty one time) I print by
                  adding lines to a listbox. Then I can scroll back and forth to see
                  what happened. (Don't forget to turn off sorting, or put line numbers
                  in front of your text).


                  ------------------
                  Thanks,

                  John Kovacich
                  Ivory Tower Software
                  www.i-tower.com

                  Try MsgBoxPlus for easy MSGBOX's with custom buttons and graphic backgrounds.
                  Thanks,

                  John Kovacich
                  Ivory Tower Software

                  Comment


                  • #10
                    A BIG thanks to everyone who shared their knowledge with me.
                    I was able convert my DOS PB program to PBWIN. I have a
                    friend who is a die heart linux/perl programmer. When I
                    showed him the response given to members of the PB forum
                    he was very impressed. Now he is looking forward to a version
                    of PB for Linux. Again thanks for the help. I’m sure I
                    will be needing more.
                    Jerry


                    ------------------

                    Comment

                    Working...
                    X