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

Hi,

I'm writing a small program using QBasic which involves drawing small
right-angled triangles in Screen Mode 12.

I need to label the corners of these triangles with letters such as 'A,B,C'
but cant seem to find an command that allows me to 'plot' text characters to
a particular point on the graphics screen.

Any way of doing this?

Thanks
Jeremy



Sun, 19 Jun 2005 23:21:17 GMT  
 sought after qbasic command?

Quote:
> I need to label the corners of these triangles with letters such as
'A,B,C'
> but cant seem to find an command that allows me to 'plot' text characters
to
> a particular point on the graphics screen.

> Any way of doing this?

You're could use LOCATE using text screen coordinates (column 1-80, row
1-25) and get as close as possible to your graphics points.  There is a way
to do what you want but it's messy.  First you PRINT the text to the
graphics screen.  Now GET a rectangle just enclosing the text.  Clear the
text off the screen.  Now you can PUT that rectangle with the text in it at
any graphics coordinate.

Tom Lake



Sun, 19 Jun 2005 23:54:49 GMT  
 sought after qbasic command?
-> I'm writing a small program using QBasic which involves drawing small
-> right-angled triangles in Screen Mode 12.

-> I need to label the corners of these triangles with letters such as 'A,B,C'
-> but cant seem to find an command that allows me to 'plot' text characters to
-> a particular point on the graphics screen.

You should be able to use LOCATE to position the cursor, then simply
PRINT the letters. But this means that you must figure out where, on
the 80 x 25 (I think) text screen the letters should go. It isn't
difficult, but you don't have as accurate control over the position of
the letters as you might like. You can't place them to the exact pixel.

An alternative, which is more flexible but trickier and slower, would
be to PSET the pixels that make up each letter. This would let you
place the letters exactly where you want. But you'd need some sort of
library of letter-shapes - unless you do something tricky like PRINTing
each letter in the corner of the screen, than reading the pixels that
are set and copying them to the desired location.

I generally use LOCATE, and adjust the graphics, if necessary, to match
the available positions of the letters.

                                dow



Mon, 20 Jun 2005 05:47:35 GMT  
 sought after qbasic command?
..interesting, and suppose you want to print that out that graphics
screen, anyway of doing that?
Quote:

> -> I'm writing a small program using QBasic which involves drawing small
> -> right-angled triangles in Screen Mode 12.

> -> I need to label the corners of these triangles with letters such as 'A,B,C'
> -> but cant seem to find an command that allows me to 'plot' text characters to
> -> a particular point on the graphics screen.

> You should be able to use LOCATE to position the cursor, then simply
> PRINT the letters. But this means that you must figure out where, on
> the 80 x 25 (I think) text screen the letters should go. It isn't
> difficult, but you don't have as accurate control over the position of
> the letters as you might like. You can't place them to the exact pixel.

> An alternative, which is more flexible but trickier and slower, would
> be to PSET the pixels that make up each letter. This would let you
> place the letters exactly where you want. But you'd need some sort of
> library of letter-shapes - unless you do something tricky like PRINTing
> each letter in the corner of the screen, than reading the pixels that
> are set and copying them to the desired location.

> I generally use LOCATE, and adjust the graphics, if necessary, to match
> the available positions of the letters.

>                                 dow



Tue, 21 Jun 2005 02:14:32 GMT  
 sought after qbasic command?
About the only way I know of is to use add interrupt code (search google) and then
call the printscreen interrupt.  If you boot your computer and load graphics.com in
your autoexec it will cause the printscreen interrupt to use graphics.com to print.
There is a file called graphics.pro that comes with DOS that can be edited for your
particular printer.  If you need more help I'll dig up some of my routines, but I use
QB4.5 and PDS 7.1.  The routines are the same except QBasic requires a seperate
routine to handle interrupt calls.
Quote:

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


> > -> I'm writing a small program using QBasic which involves drawing small
> > -> right-angled triangles in Screen Mode 12.

> > -> I need to label the corners of these triangles with letters such as 'A,B,C'
> > -> but cant seem to find an command that allows me to 'plot' text characters to
> > -> a particular point on the graphics screen.

> > You should be able to use LOCATE to position the cursor, then simply
> > PRINT the letters. But this means that you must figure out where, on
> > the 80 x 25 (I think) text screen the letters should go. It isn't
> > difficult, but you don't have as accurate control over the position of
> > the letters as you might like. You can't place them to the exact pixel.

> > An alternative, which is more flexible but trickier and slower, would
> > be to PSET the pixels that make up each letter. This would let you
> > place the letters exactly where you want. But you'd need some sort of
> > library of letter-shapes - unless you do something tricky like PRINTing
> > each letter in the corner of the screen, than reading the pixels that
> > are set and copying them to the desired location.

> > I generally use LOCATE, and adjust the graphics, if necessary, to match
> > the available positions of the letters.

> >                                 dow



Tue, 21 Jun 2005 06:29:41 GMT  
 sought after qbasic command?
-> ...interesting, and suppose you want to print that out that graphics
-> screen, anyway of doing that?

Sure. The following is a demo program of some QBasic routines that will
copy whatever is on a SCREEN 11 screen to an Epson-type printer. SCREEN
12 is basically the same as SCREEN 11 except for the colour, so the
same routines should work for that, too, in monochrome. I don't have a
routine that will operate a colour printer. That's a challenge for you!

There are three routines demo'd in this progam, which print out the
image in different orientations on the paper. Choose whichever you
wish.

                               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

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



Tue, 21 Jun 2005 07:04:58 GMT  
 sought after qbasic command?

Quote:

>Hi,

>I'm writing a small program using QBasic which involves drawing small
>right-angled triangles in Screen Mode 12.

>I need to label the corners of these triangles with letters such as 'A,B,C'
>but cant seem to find an command that allows me to 'plot' text characters to
>a particular point on the graphics screen.

>Any way of doing this?

On startup, print "ABC" to the screen then use "GET" to get the pixels
into a graphic (do each letter separately of course). Then you can "PUT"
each graphic wherever you like it on screen.

In Screen 12 (if memory serves correctly) this will mean that the printed
"ABC" will be seen for a split second but you may be able to do this part
in a hidden Screen 9 before switching to Screen 12 to "PUT" the characters
(I can't remember if this works?).

Since you're only working with 3 letters, it would also be quite easy to
design your own characters, whatever size you want, and "PSET" these to
screen then "GET" them ready to use. This is easily done using "DATA" and
"READ" statements. Of course, if you want to use other characters or
different colours or other variations, you may need to create separate
graphics for each.

I've used a variation of this method to create "embossed" letters by
PUTting the same characters back on top of themselves but offest by one
pixel up and across then GETting this again as a new graphic. Playing with
OR, XOR, PSET etc produces interesting results.

You can do all this once then save the data to a file and load it at
startup so that you no longer need to actually print the characters to
screen everytime the program starts.  These data files could then be used
in other programs too. I seem to recall using "BSAVE" to put data into a
file then using "BLOAD" to load that data into a variable rather than
directly to the screen (I think this required variable pointers for both
actions). This variable is then "PUT" to screen as normal. (I used this
method to design and save an entire deck of graphic playing cards for use
in a Blackjack game. It's fast because there's no need for any drawing,
printing or getting everytime game the game starts. I ended up with 52
separate data files though lately I've discovered things I never knew
about graphic variables - like "GETting" more than one graphic into a
single variable - so it is probably possible to whack it all in one file.)

Sorry if some of this is vague, I haven't played with Qbasic for years.

Andy D.

"I'm a great speller - but a hopless tpyist!"



Tue, 21 Jun 2005 10:38:39 GMT  
 sought after qbasic command?
well if you can send me a routine that'll print out Screen 12 graphics
to my Epson 780 printer I'll be eternally grateful.... =) and oh yeah,
I'm running WinME on my 'puter.

thx. for any and all help.....it'll help me do something I've been unable
to do for the last five years or so.......<=o

Quote:

> About the only way I know of is to use add interrupt code (search google) and then
> call the printscreen interrupt.  If you boot your computer and load graphics.com in
> your autoexec it will cause the printscreen interrupt to use graphics.com to print.
> There is a file called graphics.pro that comes with DOS that can be edited for your
> particular printer.  If you need more help I'll dig up some of my routines, but I use
> QB4.5 and PDS 7.1.  The routines are the same except QBasic requires a seperate
> routine to handle interrupt calls.


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


> > > -> I'm writing a small program using QBasic which involves drawing small
> > > -> right-angled triangles in Screen Mode 12.

> > > -> I need to label the corners of these triangles with letters such as 'A,B,C'
> > > -> but cant seem to find an command that allows me to 'plot' text characters to
> > > -> a particular point on the graphics screen.

> > > You should be able to use LOCATE to position the cursor, then simply
> > > PRINT the letters. But this means that you must figure out where, on
> > > the 80 x 25 (I think) text screen the letters should go. It isn't
> > > difficult, but you don't have as accurate control over the position of
> > > the letters as you might like. You can't place them to the exact pixel.

> > > An alternative, which is more flexible but trickier and slower, would
> > > be to PSET the pixels that make up each letter. This would let you
> > > place the letters exactly where you want. But you'd need some sort of
> > > library of letter-shapes - unless you do something tricky like PRINTing
> > > each letter in the corner of the screen, than reading the pixels that
> > > are set and copying them to the desired location.

> > > I generally use LOCATE, and adjust the graphics, if necessary, to match
> > > the available positions of the letters.

> > >                                 dow



Tue, 21 Jun 2005 10:49:42 GMT  
 sought after qbasic command?

-> You should be able to use LOCATE to position the cursor, then simply  
-> PRINT the letters. But this means that you must figure out where, on  
-> the 80 x 25 (I think) text screen the letters should go.  

I thought wrongly. The default text screen is 80 x 30 characters. I had
a nagging feeling that the number of rows should be an easy factor of
the number of pixels in the height of the screen, which is 480. So now
we know that each row is 16 pixels high, which makes sense.

                          dow



Wed, 22 Jun 2005 23:23:23 GMT  
 
 [ 9 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