COLORS ON QB SCREEN

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

COLORS ON QB SCREEN

Post by LEGRAND »

Good evening everybody!
Question remanent: how to transfer coloured letters from QB screen to printer in order to retrieve on report the coloured lines?
2nd question: I believe there is a code to get (and print in an opened file) a complete image or copy of the total screen.
Can somebody help?Thanks a lot.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

You can't in Qbasic! You could in QB64 though and use a USB printer to boot!

http://qb64.net/wiki/index.php?title=PRINTIMAGE

You can also GET and PUT # an entire screen image array into a BINARY file. QB64 can GET the entire screen 12 image in an 80K integer array. Not just 16 colors, but 32 bit!

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

PRINT QBCOLORS

Post by LEGRAND »

LOOKS VERY INTERESTING BUT I NEED TO LEARN ABOUT THIS QB64
Thanks a lot.
Any exemple to see quickly how it works?
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Try the example on the page after you install QB64. I changed the code to print the text red instead of just black and white.

COLOR _RGB(255, 0, 0), _RGBA(0, 0, 0, 0) 'RED text on clear background

The numbers inside the brackets refer to Red, Green, Blue color levels from 0 to 255.

The _RGBA color background sets the Alpha transparency to clear so that the white background shows through and doesn't use any ink.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
GarryRicketson
Veteran
Posts: 90
Joined: Fri Jul 16, 2010 10:02 am
Location: Cuencame,Durango,Mexico
Contact:

PRINT QBCOLORS_qb64

Post by GarryRicketson »

LEGRAND: LOOKS VERY INTERESTING BUT I NEED TO LEARN ABOUT THIS QB64
Ijust wanted to add it is real easy to install QB64,..only takes a couple of minuets.....Alot or most of what you already know about qbasic,can work in QB64, plus more things (commands),.. Ted knows alot more about it then me, though...
From Garry
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

QB64

Post by LEGRAND »

The code you gave to try on QB64 page looks wrongTell me once you have your instructions typed on the page, where you have to put it to make it printed.
Thanks
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

QB64

Post by LEGRAND »

Afraid my request was completly unclear.Sorry.
Let's try again.Suppose I wrote a program, with some results in color
(using COLOR 4,0 zb).I would like that, printing on printer with instruction LPRINT, the results on paper appear with the same (or other?) colors.
If I understood well, I have first to copy my program from QB4.5 for instance to QB64.Then....I'm lost.
What I would need is something like a tutorial. is that existing?
(I use the code you gave me last year concerning LPRINT. My printer is ok for that)
I read also that QB64 is able to play SIMULTANEOUSLY 2 (more?) sounds
an acchord in other words. What are the instructions?
With my kindest regards.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

With _PRINTIMAGE you can print something that was just printed to the screen originally. QB64 allows you to use HIDDEN screen image pages and PUT them later. The trick is to make the page resolution the same as the the paper size your printer is set for so you make a custom screen page that is 640 X 900 for a 210mm X 297mm sheet.

Code: Select all

_TITLE "Print Preview ASCII Table"
SCREEN _NEWIMAGE(640, 900, 256)    'size is proportional to 210mm X 297mm paper

OUT &H3C8, 0: OUT &H3C9, 63: OUT &H3C9, 63: OUT &H3C9, 63 'white background saves ink!

Align 8, 2, "ASCII and Extended Character Code Table using CHR$(n%)"
PRINT STRING$(80, 223)
COLOR 40 '12
PRINT " ";
FOR i% = 0 TO 13
  PRINT i%;: SetCHR CSRLIN, POS(0), 40, i%
  LOCATE CSRLIN, POS(0) + 1
NEXT i%
FOR i% = 14 TO 16
  PRINT i%; CHR$(i%);
NEXT
LOCATE CSRLIN + 1, 2
FOR i = 17 TO 27
  PRINT i; CHR$(i);
NEXT
FOR i% = 28 TO 31
  PRINT i%;: SetCHR CSRLIN, POS(0), 40, i%
  LOCATE CSRLIN, POS(0) + 1
NEXT i%
LOCATE CSRLIN + 1, 2
COLOR 2: PRINT 32; CHR$(32);
FOR i% = 33 TO 255
  SELECT CASE i%
    CASE 45, 58, 71, 84: LOCATE CSRLIN + 1, 1
    CASE IS > 96: IF (i% - 97) MOD 11 = 0 THEN LOCATE CSRLIN + 1, 1
  END SELECT
  SELECT CASE i%
    CASE 48 TO 57: COLOR 9 'denotes number keys 48 to 57
    CASE 65 TO 90: COLOR 5 ' A to Z keys 65 to 90
    CASE 97 TO 122: COLOR 36 'a to z keys 97 to 122
    CASE 169, 170: COLOR 6
    CASE 127 TO 175: COLOR 42
    CASE 176 TO 223: COLOR 6 'drawing characters 176 to 223
    CASE IS > 223: COLOR 42
    CASE ELSE: COLOR 2
  END SELECT
  IF i% = 98 OR i% = 99 OR i% = 100 THEN PRINT SPACE$(1);
  PRINT " "; i%; CHR$(i%);
NEXT i%
COLOR 3: PRINT "= NBSP(Non-Breaking Space)"
COLOR 8: PRINT STRING$(80, CHR$(220))
Border 8
COLOR 4: LOCATE 27, 4: PRINT "7) BELL, 8) Backspace, 9) Tab, 10) LineFeed(printer), 12) FormFeed(printer)"
LOCATE 28, 4: PRINT "  13) Return, 26) End Of File, 27) Escape  30) Line up, 31) Line down "

Align 13, 29, "Press Ctrl + P to PRINT!"

DO: SLEEP: K$ = INKEY$: LOOP UNTIL K$ <> ""
Align 13, 29, SPACE$(50)
IF K$ = CHR$(16) THEN
  _PRINTIMAGE 0 '<<<<<<<<<<<< 0 designates the current screen to PRINTER
  Align 11, 29, "Use the ASCII Table for a reference of the codes!"
  SOUND 700, 4
END IF
K$ = INPUT$(1)
SYSTEM

SUB Align (Tclr, Trow, txt$)
Tcol = 41 - (LEN(txt$) \ 2)
COLOR Tclr: LOCATE Trow, Tcol: PRINT txt$;
END SUB

SUB Border (clr%)
COLOR clr%
FOR row = 1 TO 30
  LOCATE row, 1: PRINT CHR$(179);
  LOCATE row, 80: PRINT CHR$(179);
NEXT row
  LOCATE 1, 1: PRINT STRING$(80, 196);
  LOCATE 30, 1: PRINT STRING$(80, 196);
LOCATE 1, 1: PRINT CHR$(218);
LOCATE 1, 80: PRINT CHR$(191);
LOCATE 30, 1: PRINT CHR$(192);
LOCATE 30, 80: PRINT CHR$(217);
END SUB

SUB SetCHR (Trow, Tcol, FG, ASCode)
Srow = 16 * (Trow - 1): Scol = 8 * (Tcol - 1) 'convert text to graphic coordinates
COLOR FG: _PRINTSTRING (Scol, Srow), CHR$(ASCode)
END SUB
The ASCII Table was from a SCREEN 12 page in my Qbasic Demo. I made a custom screen with _NEWIMAGE making it deeper so that the image is not stretched to fit the paper size. That would distort the image printed.

_PRINTSTRING is a graphical print that can print the unprintable ASCII control characters. You will note that it prints the text colors that you are used to in Qbasic.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

QBCOLORS

Post by LEGRAND »

Except the first line I had to erase, i got printed the complete page
I must now try myself to fully take advantage of it.
Now, qustion: Can I open in this QB64 all my previous programs written for QB?(and run them?)

I would like also some info concerning sounds playing and additionnal tools available with this QB64.
That's look to be a great improvement .
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

MOST of the Qbasic keywords are supported. Here are the ones not supported:

http://qb64.net/wiki/index.php?title=Ke ... ed_by_QB64

PLAY supports multiple notes using a comma between them and V can set volume.

QB64 sound statements support most types of sound files: Keywords begin with _SND in WIKI list.

_SNDRAW can make sounds using wave form values between -1 and 1.

http://qb64.net/wiki/index.php?title=Ke ... phabetical

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

QBCOLORS

Post by LEGRAND »

Thanks. I come back later after some tests
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

BTW, QB64 sounds come from the sound card, not the internal speaker you may not have.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Post Reply