sought after qbasic command? 
Author Message
 sought after qbasic command?

-> ...interesting, and suppose you want to print that out that graphics
-> screen, anyway of doing that?

Yes. But didn't we discuss this a few weeks ago?

Here is a QBasic program that demonstrates routines that will print out
SCREEN 11 images to a dot-matrix Epson-type printer. (SCREEN 11 is very
like SCREEN 12, except for the colour.) Other types of printer require
different routines.

                            dow

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

' LCOPYDEM.BAS
' Demo of LCopy11 routines
' David O. Williams  2001

' Demonstrates 3 SUBs that copy SCREEN 11 to printer.
' The SUBs print the image in three different orientations.
' Most other routines are limited to one orientation.
' Note: Printer must be Epson-compatible.
' Make sure printer is ready before running program.

DECLARE SUB LCopy11 ()
DECLARE SUB LCopy11L ()
DECLARE SUB LCopy11R ()

SCREEN 11

' draw demo diagram
CIRCLE (320, 240), 200
LINE (200, 200)-(250, 200)
CIRCLE (420, 200), 20
CIRCLE (420, 200), 3
LINE (320, 220)-(320, 260)
LINE (200, 300)-(320, 350)
LINE (320, 350)-(440, 300)
LOCATE 30, 38
PRINT "SMILE!";

' copy to printer without rotation
CALL LCopy11

' copy to printer with rotation 90 degrees to left
CALL LCopy11L

' copy to printer with rotation 90 degrees to right
CALL LCopy11R

' terminate
SCREEN 0
END

SUB LCopy11

' Copies monochrome SCREEN 11 image to printer, with printed image
' aligned with long axis across the page. Note: To fit on 8-inch
' wide paper, 32-pixel margins on both sides are not printed.

  DEFINT A-Y
  DEFLNG Z

  DIM V(0 TO 7), A(0 TO 7, 4 TO 75)' col's 0-3 and 76-79 not printed

  V(7) = 1  ' reVerse-order bits
  FOR X = 7 TO 1 STEP -1
    V(X - 1) = V(X) + V(X)
  NEXT

  F = FREEFILE
  OPEN "PRN" FOR BINARY AS F

  DEF SEG = &HA000
  OUT &H3CE, 4
  OUT &H3CF, 0

  N$ = STRING$(8, 0)                    ' 8 nulls for empty square

  E$ = CHR$(27)                         ' ESC character

  L$ = E$ + "C" + CHR$(0) + CHR$(11)    ' page length = 11 inches
  PUT F, , L$

  L$ = E$ + "A" + CHR$(8)               ' set printer to 8/72 lpi
  PUT F, , L$

  Z = 4

  FOR S = 0 TO 59  ' 60 stripes, each 8 rows deep

    N = -1             ' null-stripe flag

    FOR R = 0 TO 7             ' read 8 rows into array
      FOR C = 4 TO 75
        A(R, C) = PEEK(Z)
        IF N THEN IF A(R, C) THEN N = 0
        Z = Z + 1
      NEXT
      Z = Z + 8
    NEXT

    IF NOT N THEN    ' not null stripe

      L$ = E$ + "*" + CHR$(5) + MKI$(576)  ' set plotter mode
      PUT F, , L$

      FOR C = 4 TO 75
        Q = 0
        FOR R = 0 TO 7
          IF A(R, C) THEN Q = 1: EXIT FOR
        NEXT
        IF Q THEN       ' not null square
          FOR Y = 0 TO 7    ' analyse 8 bits per byte
            B = 0
            FOR R = 0 TO 7  ' 8 bytes to be analysed
              IF A(R, C) AND V(Y) THEN B = B OR V(R)
            NEXT R
            L$ = CHR$(B)  ' send byte to printer
            PUT F, , L$
          NEXT Y
        ELSE    ' null square
          PUT F, , N$
        END IF
      NEXT C

    END IF

    L$ = CHR$(13) + CHR$(10)            ' terminate line (stripe)
    PUT F, , L$

  NEXT S

  L$ = CHR$(12)                         ' form feed
  PUT F, , L$


  PUT F, , L$

  CLOSE F

  DEF SEG

END SUB

DEFSNG A-Z
SUB LCopy11L

' Copies monochrome SCREEN 11 image to printer, with long
' axis of image along length of page. This version rotates
' image to Left, so right-hand edge of screen is at top.

  DEFINT A-Y
  DEFLNG Z

  DIM A(0 TO 255)    ' numbers with reversed bit order

  A(0) = 0           ' fill look-up array
  P = 1
  Q = 128
  DO
    FOR Y = 0 TO P - 1
      A(Y + P) = A(Y) OR Q
    NEXT
    IF Q = 1 THEN EXIT DO
    P = P + P
    Q = Q \ 2
  LOOP

  F = FREEFILE
  OPEN "PRN" FOR BINARY AS F

  DEF SEG = &HA000
  OUT &H3CE, 4
  OUT &H3CF, 0

  E$ = CHR$(27)                         ' ESC character
  P$ = STRING$(48, 0)                   ' centring string of nulls
  Q$ = STRING$(480, 0)                  ' null line

  L$ = E$ + "C" + CHR$(0) + CHR$(11)    ' page length = 11 inches
  PUT F, , L$

  L$ = E$ + "A" + CHR$(8)               ' set printer to 8/72 lpi
  PUT F, , L$

  FOR C = 79 TO 0 STEP -1         ' 80 image columns = printer lines

    S$ = ""      ' initialize line

    FOR Z = C TO 38320 + C STEP 80  ' 480 bytes per column
      S$ = S$ + CHR$(A(PEEK(Z)))
    NEXT

    IF S$ <> Q$ THEN ' not null line

      L$ = E$ + "*" + CHR$(5) + MKI$(576)  ' set plotter mode
      PUT F, , L$
      PUT F, , P$   ' centre line
      PUT F, , S$   ' send line
      PUT F, , P$   ' fill line

    END IF

    L$ = CHR$(13) + CHR$(10)           ' terminate line
    PUT F, , L$

  NEXT C

  L$ = CHR$(12)                         ' form feed
  PUT F, , L$


  PUT F, , L$

  CLOSE F

  DEF SEG

END SUB

DEFSNG A-Z
SUB LCopy11R

' Copies monochrome SCREEN 11 image to printer, with long
' axis of image along length of page. This version rotates image
' 90 degrees to Right (clockwise).

  DEFINT A-Y
  DEFLNG Z

  F = FREEFILE
  OPEN "PRN" FOR BINARY AS F

  DEF SEG = &HA000
  OUT &H3CE, 4
  OUT &H3CF, 0

  E$ = CHR$(27)                         ' ESC character
  P$ = STRING$(48, 0)                   ' centring string of nulls
  Q$ = STRING$(480, 0)                  ' null line

  L$ = E$ + "C" + CHR$(0) + CHR$(11)    ' page length = 11 inches
  PUT F, , L$

  L$ = E$ + "A" + CHR$(8)               ' set printer to 8/72 lpi
  PUT F, , L$

  FOR C = 0 TO 79         ' 80 image columns = printer lines

    S$ = ""      ' initialize line

    FOR Z = 38320 + C TO C STEP -80      ' 480 bytes per column
      S$ = S$ + CHR$(PEEK(Z))
    NEXT

    IF S$ <> Q$ THEN ' not null line

      L$ = E$ + "*" + CHR$(5) + MKI$(576)  ' set plotter mode
      PUT F, , L$
      PUT F, , P$   ' centre line
      PUT F, , S$   ' send line
      PUT F, , P$   ' fill line

    END IF

    L$ = CHR$(13) + CHR$(10)           ' terminate line
    PUT F, , L$

  NEXT C

  L$ = CHR$(12)                         ' form feed
  PUT F, , L$


  PUT F, , L$

  CLOSE F

  DEF SEG

END SUB

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



Sun, 07 Aug 2005 12:17:45 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. sought after qbasic command?

2. Help: Seek command won't seek

3. getting a qbasic program to run the command to start another non qbasic

4. Seeking Help with Qbasic

5. Seeking QBASIC Source

6. Help with the SEEK command

7. seek command

8. Problem using SEEK command. VB4->Access

9. Lock on seek command

10. Linking Data1 scroll position with seek command result

11. Linking Data1 scroll position with seek command result

12. Help for seek command

 

 
Powered by phpBB® Forum Software