Announcement

Collapse
No announcement yet.

Problem with DOS PB in Windows 98

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

  • Problem with DOS PB in Windows 98

    I have written two procedures in PB3.2 to read the screen so as
    to save its contents, to be later shown again. In other words,
    by saving part of the screen, I can restore that part if over-
    written. Here is the code, which does not work in WINDOWS 98,
    nor in WINDOWS 95 if the procedure is called by another procedure
    in a different module.
    Code:
    FUNCTION PARTIAL.LINE.CAPTURE$(byval R,byval C, byval W) PUBLIC
    IF W=0 THEN W=PbvScrnCols+1-C
    x$=space$(2*W):count=1
    for J=C to W-1+C
        if J<81 then
           Mid$(x$,count,1)=chr$(screen(r,j))
           incr count
           Mid$(x$,count,1)=chr$(screen,r,j,1))
           incr count
         end if
    Partial.line.capture$=x$
    end function
     
    '---------------------------------------------
     
    FUNCTION PARTIAL.LINE.CHAR$(byval R,byval C,byval W) PUBLIC
       IF W=0 THEN W=PbvScrnCols+1-c
       x$=partial.line.capture$(r,c,w)
       y$=spaces(w):j=1
       for k=1 to 2*w step 2
           mid$(y$,j,1)=mid$(x$,k,1)
           incr j
       next k
       partial.line.char$=y$
    end function
    thanks for the help.
    Pat


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

  • #2
    Are you sure the code is actually being executed? Can you step through it with the debugger.

    It seems possible that the code is somehow not be $INCLUDEd or $LINKed and that your code is using a pair of local string variables instead. Using $DIM ALL will help, but may not be practical if your code is very large.

    Basically, there is nothing in those functions that should be affected by Windows.

    If memory is not a problem, maybe try using these routines that save a snapshot & restore a snapshot of the entire screen (assuming 80x25).
    Code:
    ' Save screen as snapshot into String Variable
    SUB SaveScreen(a$) LOCAL public
        def seg = pbvScrnBuff \ 65536
        a$ = PEEK$(0,4000)
        def seg
    END SUB
     
    ' Restore screen from snapshot held in String Variable
    SUB RestoreScreen(BYVAL a$) LOCAL public
        def seg = pbvScrnBuff \ 65536
        POKE$ 0, a$
        def seg
    END SUB
    These require approx 4K per snapshot, but are very fast.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Lance,
      Thanks for your quick reply. Saving the whole screen, in my
      application, won't work, because I want to save several lines
      after modifying parts of the screen. When I recalled the original
      screen, it would then overwrite the screen changes made after
      saving the screen.
      Yes, I did step thru it. Other code in the same module works. It
      seems that the "SCREEN" function doesn't work in Windows 98 and
      when this function is called by a different module, both of which
      are linked to the MAIN module.
      The function had been placed in a ".PBU" and works in DOS with
      WINDOWS 95. In fact, any changes I make to a program in Windows
      98, using PowerBASIC, never seem to change. However, if I compile
      these changes on the DOS (Windows 95) machine, I can then simply
      copy them to the Windows 98 machine, and except for this function,
      the programs work.
      It seems that Windows 98 doesn't have a "REAL" DOS; that is, a
      DOS that functions like the normal DOS should. Any hints or
      have you received other such errors from other users?
      Thanks in advance.
      Pat

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

      Comment


      • #4
        Peek$ and Poke$ is still your best choice.

        You don't have to copy and paste back the whole screen with
        Lances little Subroutines. Just change your starting address
        and the number of bytes to copy only the rows you want.


        Code:
        SUB SaveScreen(a$) LOCAL public
            def seg = pbvScrnBuff    
            a$ = PEEK$(0,320) ' will copy the first two rows since theres   
            def seg           ' 160 bytes in each row
        END SUB 
        
        
        SUB RestoreScreen(BYVAL a$) LOCAL public    
            def seg = pbvScrnBuff    
            POKE$ 0, a$    'Pokes$ starting address will stay the same
            def seg
        END SUB
        
        
        If you really want to zero in on an area of the screen and not copy
        full rows, you can use routines similar to the following. They 
        not only let you copy an area but they let you put it back in a 
        different location. They were written in PB3.0, I think they will
        still work with 3.2. 
        
        
        SUB textgetz (r1%, c1%, r2%, c2%, sa$()) 
             'MouseHideCursor        'Mouse cursor will discolor screen
             DEF SEG = &HB800        'Address of a color screen
             ERASE sa$               'erase last copy
             DECR r1%
             colx% = (c2% - c1%) * 2                'get number of bytes
             col1% = (c1% * 2) + (r1% * 160) - 2    'Get start address
             ro% = r2% - r1%                        'get rows to copy
             FOR x = 1 TO ro%
        	sa$(x) = peek$(col1%, colx%)  'Load each row portion in array
        	INCR col1%, 160               'Starting address for next row
             NEXT x
             'MouseShowCursor                  'turn mouse back on
        END SUB
        
        
        SUB textputz (r1%, c1%, r2%, c2%, sa$()) 
             'MouseHideCursor
             DEF SEG = &HB800
             DECR r1%: DECR c1%
             col1% = (c1% * 2) + (r1% * 160)
             ro% = r2% - r1%
             FOR x = 1 TO ro% + 1
               POKE$  col1%, sa$(x)
               INCR col1%, 160
             NEXT x
             'MouseShowCursor
        END SUB
        r1% is the top row of the rectangle
        r2% is the bottom row
        c1% is the starting column
        c2% is the ending column

        If you want to copy an area starting at row 3 and column 10 and
        end at row 15 and column 20, you would call

        TextGetz 3, 10, 15, 20, sa$()

        to put it back

        TextPutz 3, 10, 15, 20, sa$()

        Anyway, it works for me and works in every windows I ever tried.
        I'm pretty sure I've used the DOS Screen Function in windows
        before and it worked.

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




        [This message has been edited by Jerry Fielden (edited May 16, 2001).]

        Comment


        • #5
          Pat - for whatever it's worth, your routine (and the SCREEN(r,c,a) statement) does work in a DOS box on my Win98 system, both maximized and as a window. Nor do I have any problems such as you describe, compiling PB/DOS stuff on Win98 machines...

          Can you be a little more specific about what you mean by "not working"? Do your functions fail to execute at all, execute but return a null string, or execute and return something other than what you expected to get back?

          Ah - just noticed something on re-reading the thread. You're using PowerBASIC 3.2, not 3.5? Lance - any known issues between 3.2 and Win98 that could explain this?


          [This message has been edited by Gary Akins (edited May 17, 2001).]

          Comment


          • #6
            Nope... none that I am aware of, and certainly none with the SCREEN function.



            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Gee Gang! Thanks.
              Gary,
              To be more specific, a null value is returned, as tho the
              call was never made.

              Jerry,
              Thanks much for your alternate routine, using PEEK$ and poke$.
              It certainly is more primative than SCREEN which I think uses
              PEEK$ anyway. However, my basic problem remains. I cannot use
              SCREEN(r,c,1) to read the screen in a DOS window under WINDOWS 98.
              I'll try some other routines that use SCREEN and get back to all
              of you.

              Again thanks.
              Pat

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

              Comment


              • #8
                SCREEN almost certainly goes through BIOS calls (or possibly direct memory access,
                in text mode at least). The only likely prospect for any sort of failure would be
                a bad display driver. Make sure you've got the latest driver for your display adapter.
                If that doesn't help, try replacing the display adapter entirely. Odds are about
                infinite that you're being hosed by the video card.


                ------------------
                Tom Hanlin
                PowerBASIC Staff

                Comment


                • #9
                  Gang!

                  Again thanks.
                  I tried using SCREEN and PEEK$/POKE$ in a new program, dedicated
                  only to saving a partial line. I then placed the code in a UNIT
                  and then called it from another unit. In every case it worked.
                  Maybe I had better look at the original code that caused the
                  problem. It may have nothing to do with SCREEN or PEEK/POKE.
                  Thanks again.
                  Pat

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

                  Comment


                  • #10
                    Pat - there were a couple of typos in the code you initially posted, and a missing NEXT statement; but, since the code wouldn't compile at all in its posted form (as opposed to compiling, but "not working"), I just assumed they'd been introduced while typing your code into the forum, as opposed to being part of your original code...

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

                    Comment

                    Working...
                    X