QuickBasic programming help? 
Author Message
 QuickBasic programming help?

Hi!
        Am having trouble with QuickBasic and Windows XP Pro.
Since the upgrade, can't access the printer properly, and am told that
is deliberate within XP, (for originally DOS programmes although I can't
imagine why?)
I want to print the screen from within the programmes, at any of the
various input lines. And  there are a lot of separate programmes.
So, thought I would copy the screen to a text file, and print later. It
is all text, no graphics.

Now, tried:
    Declare sub copi2doc
    Key 7,crtlr$ + cursorup$      ' these variables have values assigned
    on key(7) call copi2doc       ' with/without  call, (0), ( )  and
gosub
    key(7) ON

The separate sub (in a .lib file) asks for a file name, scans the screen
in two loops, (rows and cols) and prints each row to the given file.

It doesn't work.

"Sub not found", "expected gosub" are some of the error messages
presented!

What am I doing wrong?

If I use ON KEY(7) gosub XXXX,
  and XXXX is in the main programmes abd calls copi2doc it does indeed do
as needed, but I then can't return to the original place in the
programme! It moves on beyond the input request.

Really, I suppose I need a patch to get round XP's blocking access to
the printer?

(It's the same in dBase, except that a few lines do print, but anything
from about 6 to 12, variable!)

I know that alt+print screen puts the window into the clipboard, but
it's as graphics. I want a plain text file. Can it be converted to a
text file?

Any help appreciated.
--
Wilf,  who remembers "PRESS PLAY ON TAPE #1"
         (If replying direct, attend to anti-spam insert in
          sender address. To reduce spam, most e-mails are rejected)



Wed, 23 Nov 2005 03:00:10 GMT  
 QuickBasic programming help?

Quote:
> Now, tried:
>     Declare sub copi2doc
>     Key 7,crtlr$ + cursorup$      ' these variables have values assigned
>     on key(7) call copi2doc       ' with/without  call, (0), ( )  and
> gosub
>     key(7) ON

> The separate sub (in a .lib file) asks for a file name, scans the screen
> in two loops, (rows and cols) and prints each row to the given file.

> It doesn't work.

> "Sub not found", "expected gosub" are some of the error messages
> presented!

> What am I doing wrong?

We'd need to see sub copi2doc to see what might be wrong.  The syntax of ON
KEY is definitely GOSUB, not CALL.  Get rid of the declare sub at the
beginning.  That's only used with modern SUBprograms, not subroutines.

Tom Lake



Wed, 23 Nov 2005 04:36:07 GMT  
 QuickBasic programming help?


Quote:
>> What am I doing wrong?

>We'd need to see sub copi2doc to see what might be wrong.  The syntax of ON
>KEY is definitely GOSUB, not CALL.  Get rid of the declare sub at the
>beginning.  That's only used with modern SUBprograms, not subroutines.

>Tom Lake

Thanks for that. I think it will help me to explain the difficulty a
little more clearly.

Under earlier versions of Windows, I ran quite a few QuickBasic 4.5
programmes. From within them, (at an input request line), I could do a
screen print by simply pressing "print screen".
With Windows XP Pro, the print screen doesn't work.
(Neither does cntrl- shift- etc. except to put a graphic picture of the
text into Clipboard. This I find difficult to edit!)
Now, there are a lot of programmes, so I don't want to re-write them all
under VB. Or add a subroutine to each; surely I can just use the one
sub- programme from a library?
The subroutine is now located in MYLIB.BAS, (should it be MYLIB.LIB? If
so, how do I load it, and load/run the menu.bas programme at the same
time?)
The sub programme is:
'            MYLIB.BAS        A  library of SUBs for ciphers progs.

  SUB SCRN2DOC
      ' Copy screen to a file for later printing
      LOCATE 22, 50: INPUT "File name: ", FLN$
      FLN$ = FLN$ + ".TXT"
      OPEN FLN$ FOR APPEND AS #1
      FOR SCRNLN = 1 TO 23
          X$ = ""
          FOR SCRNRW = 1 TO 79
             XZ = SCREEN(SCRNLN, SCRNRW)
             X$ = X$ + CHR$(XZ)
          NEXT
          PRINT #1, X$
    NEXT
    CLOSE #1
  END SUB

Now, I want to call this sub programme from within the other basic
programmes, and after execution return to the line requesting an input.

Or, convert the graphic image that an  alt-print screen key combination
puts the Clipboard into a  text file.

Or just print the screen when required!!!!!

Now, is that any clearer?
Hope so, and that it leads to  a solution!

Thanks anyway,

--
Wilf,  who remembers "PRESS PLAY ON TAPE #1"
        (If replying direct, attend to anti-spam insert in
         sender address. To reduce spam, most e-mails are rejected)



Fri, 25 Nov 2005 02:42:35 GMT  
 QuickBasic programming help?

Quote:
> >We'd need to see sub copi2doc to see what might be wrong.  The syntax of
ON
> >KEY is definitely GOSUB, not CALL.  Get rid of the declare sub at the
> >beginning.  That's only used with modern SUBprograms, not subroutines.

> >Tom Lake

> Thanks for that. I think it will help me to explain the difficulty a
> little more clearly.

ON KEY doesn't interrupt an INPUT statement so you'd have to write a routine
ising INKEY$ that simulates the built-in INPUT statement.  Once that's done,
the following will print the screen to a file when F1 is pressed: (my
example just prints nonsense characters over and over)

' $INCLUDE: 'MYLIB.BAS'        A  library of SUBs for ciphers progs.
ON KEY(1) GOSUB PrintScreen
KEY (1) ON
CLS
DO
    a = INT(RND * 220) + 32
    c$ = CHR$(a)
    PRINT c$; " ";
LOOP
END
PrintScreen:
SCRN2DOC
RETURN

' $INCLUDE: 'MYLIB.BAS'        A  library of SUBs for ciphers progs.
DECLARE SUB SCRN2DOC ()
ON KEY(1) GOSUB PrintScreen
KEY(1) ON
' Rest of program goes here
CLS
DO
    a = INT(RND * 220) + 32
    c$ = CHR$(a)
    PRINT c$; " ";
LOOP
END
PrintScreen:
SCRN2DOC
RETURN

' MYLIB.BAS        A  library of SUBs for ciphers progs.'
SUB SCRN2DOC
    ' Copy screen to a file for later printing
    LOCATE 23, 60: INPUT "File name: ", FLN$
    FLN$ = FLN$ + ".TXT"
    OPEN FLN$ FOR OUTPUT AS #1
    FOR SCRNLN = 1 TO 24
        X$ = ""
        FOR SCRNRW = 1 TO 80
            XZ = SCREEN(SCRNLN, SCRNRW)
            X$ = X$ + CHR$(XZ)
        NEXT
        PRINT #1, X$
    NEXT
    CLOSE #1
END SUB



Fri, 25 Nov 2005 03:20:21 GMT  
 QuickBasic programming help?

You can enable the print screen keyboard button again by changing the
properties of the DOS window.  Right click your icon or shortcut for DOS and
select Properties, select the Misc tab, uncheck the Alt+PrtSc and PrtSc
buttons.  Click OK.  Reopen the DOS window.  Voila!

I don't know - can't test - if this works for all flavors of Windows 9x and
up.  I know it works in Win98SE and XP Pro.

Martin




Quote:
>> What am I doing wrong?

>We'd need to see sub copi2doc to see what might be wrong.  The syntax of ON
>KEY is definitely GOSUB, not CALL.  Get rid of the declare sub at the
>beginning.  That's only used with modern SUBprograms, not subroutines.

>Tom Lake

Thanks for that. I think it will help me to explain the difficulty a
little more clearly.

Under earlier versions of Windows, I ran quite a few QuickBasic 4.5
programmes. From within them, (at an input request line), I could do a
screen print by simply pressing "print screen".
With Windows XP Pro, the print screen doesn't work.
(Neither does cntrl- shift- etc. except to put a graphic picture of the
text into Clipboard. This I find difficult to edit!)
Now, there are a lot of programmes, so I don't want to re-write them all
under VB. Or add a subroutine to each; surely I can just use the one
sub- programme from a library?
The subroutine is now located in MYLIB.BAS, (should it be MYLIB.LIB? If
so, how do I load it, and load/run the menu.bas programme at the same
time?)
The sub programme is:
'            MYLIB.BAS        A  library of SUBs for ciphers progs.

  SUB SCRN2DOC
      ' Copy screen to a file for later printing
      LOCATE 22, 50: INPUT "File name: ", FLN$
      FLN$ = FLN$ + ".TXT"
      OPEN FLN$ FOR APPEND AS #1
      FOR SCRNLN = 1 TO 23
          X$ = ""
          FOR SCRNRW = 1 TO 79
             XZ = SCREEN(SCRNLN, SCRNRW)
             X$ = X$ + CHR$(XZ)
          NEXT
          PRINT #1, X$
    NEXT
    CLOSE #1
  END SUB

Now, I want to call this sub programme from within the other basic
programmes, and after execution return to the line requesting an input.

Or, convert the graphic image that an  alt-print screen key combination
puts the Clipboard into a  text file.

Or just print the screen when required!!!!!

Now, is that any clearer?
Hope so, and that it leads to  a solution!

Thanks anyway,

--
Wilf,  who remembers "PRESS PLAY ON TAPE #1"
        (If replying direct, attend to anti-spam insert in
         sender address. To reduce spam, most e-mails are rejected)



Fri, 25 Nov 2005 23:13:36 GMT  
 QuickBasic programming help?
Many thanks indeed for the help.
Will put it into practice as I use each programme.
Thanks again,

Quote:
>ON KEY doesn't interrupt an INPUT statement so you'd have to write a routine
>ising INKEY$ that simulates the built-in INPUT statement.  Once that's done,
>the following will print the screen to a file when F1 is pressed: (my
>example just prints nonsense characters over and over)

>' $INCLUDE: 'MYLIB.BAS'        A  library of SUBs for ciphers progs.
>ON KEY(1) GOSUB PrintScreen
>KEY (1) ON
>CLS
>DO
>    a = INT(RND * 220) + 32
>    c$ = CHR$(a)
>    PRINT c$; " ";
>LOOP
>END
>PrintScreen:
>SCRN2DOC
>RETURN

>' $INCLUDE: 'MYLIB.BAS'        A  library of SUBs for ciphers progs.
>DECLARE SUB SCRN2DOC ()
>ON KEY(1) GOSUB PrintScreen
>KEY(1) ON
>' Rest of program goes here
>CLS
>DO
>    a = INT(RND * 220) + 32
>    c$ = CHR$(a)
>    PRINT c$; " ";
>LOOP
>END
>PrintScreen:
>SCRN2DOC
>RETURN

--
Wilf,  who remembers "PRESS PLAY ON TAPE #1"
         (If replying direct, attend to anti-spam insert in
          sender address. To reduce spam, most e-mails are rejected)


Sat, 26 Nov 2005 05:14:12 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. QuickBASIC programming help needed!!!

2. Need shell for DOS program in Quickbasic!

3. Compiling QuickBasic programs

4. Comm ports and running Quickbasic programs under windows or NT

5. QuickBasic program won't detect directories under NT

6. compiling standalone programs: QuickBasic or Turbobasic?

7. A QBasic/QuickBasic Database Program....

8. Anybody using QuickBasic to create CGI programs?

9. My Ai Chat program in QuickBasic...

10. Games Programming In QuickBasic

11. Icons for compiled QuickBasic programs

12. Problem with linking a QuickBASIC program (urgent!!!!!)

 

 
Powered by phpBB® Forum Software