• Print

Author Topic: Printer Commands  (Read 199 times)

Phasedr

  • Newbie
  • *
  • Posts: 1
Printer Commands
« on: April 08, 2013, 11:37:36 AM »
Hello, i are progrming one system in QB64 for one Enterprise what need manager ones buildins expense and i have problems with the section of print, i need can send escape codes to the printer for programing type of font, size, Spacing length, space in lines and more, if any can help me with this problem, PLEASE I NEED HELP.

Phasedr

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Printer Commands
« Reply #1 on: April 08, 2013, 02:12:19 PM »
I would start with the manual for the printer that you are using.
I doubt all the codes are universal to more than just that printer

RhoSigma

  • Jr. Member
  • **
  • Posts: 75
  • 4 * 1.0079 = 4.0026
    • Email
Re: Printer Commands
« Reply #2 on: April 08, 2013, 02:22:06 PM »
Welcome to the Forum,

I assume you know the escape sequences you need to do your stuff and your question is about how to prepend the sequences with the escape character.

So try this:

seq$ = CHR$(27) + "[m"
LPRINT seq$;

or in short:

LPRINT CHR$(27);"[m";

I think this sequence was a linefeed, CHR$(27) is the escape character, you can add it to strings or use it directly in the LPRINT statement.

Regards
Download archives of my QB64 stuff:
Polygon functions: http://rhosigma-cw.net/down/GfxDemos.zip
Screen savers: http://rhosigma-cw.net/down/ScrSavers.zip
Libraries collection: http://rhosigma-cw.net/down/QB64Library.zip (extract into the QB64 folder, a new sub-folder "QB64Library" is created)

Barrykgerdes

  • Full Member
  • ***
  • Posts: 249
    • Email
Re: Printer Commands
« Reply #3 on: April 08, 2013, 02:24:27 PM »
I haven't sent escape codes to a printer since the days of dot matrix and GWbasic

However if you have the printer manual it should list the escape codes and it should be possible to "WRITE" or "PRINT"
them to the device. Print codes a generally prefixed with a control character (CHR$(xx).

see the previous post

Barry

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Printer Commands
« Reply #4 on: April 08, 2013, 05:04:58 PM »
Hi all,
    Welcome to the forum Phasedr.
OlDosLover.

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2264
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: Printer Commands
« Reply #5 on: April 08, 2013, 07:01:31 PM »
Quote from: RhoSigma on April 08, 2013, 02:22:06 PM
Welcome to the Forum,

I assume you know the escape sequences you need to do your stuff and your question is about how to prepend the sequences with the escape character.

So try this:

seq$ = CHR$(27) + "[m"
LPRINT seq$;

or in short:

LPRINT CHR$(27);"[m";

I think this sequence was a linefeed, CHR$(27) is the escape character, you can add it to strings or use it directly in the LPRINT statement.

Regards

I believe you may be referring to ANSI codes with "[m". Most dot matrix printers I controlled directly back in the 80's and 90's used the standard CHR$(10) as a line feed.  However, it has been a loooooong time so I could very well be mistaken too. :)

Barrykgerdes

  • Full Member
  • ***
  • Posts: 249
    • Email
Re: Printer Commands
« Reply #6 on: April 08, 2013, 10:17:00 PM »
I went back through my old-old GWbasic files and found this.
It initialised a dot matrix printer called a STAR DP515

Code: [Select]
10 CLS
20 REM ******************************************
30 REM *                                        *
40 REM *          S T A R   D P 5 1 5           *
50 REM *                                        *
60 REM *     Printer initialization  Ver.1.1    *
70 REM *                                        *
80 REM ******************************************
100 PRINT "**************************************"
110 PRINT "*        S T A R   D P 5 1 5         *"
120 PRINT "*   Printer initialization  Ver.1.1  *"
130 PRINT "**************************************"
150 REM -----------------------------------------
160 REM *         Initialize Printer            *
170 LPRINT CHR$(27);"@";
180 REM -----------------------------------------
190 INPUT "1.Set left margin max. 137        :";L
200 N=L:LPRINT CHR$(27);"M";CHR$(N);
210 REM -----------------------------------------
220 INPUT "2.Set right margin max. 137       :";E
230 N=E:LPRINT CHR$(27);"Q";CHR$(N);
240 REM -----------------------------------------
250 INPUT "3.Set character ROM 0 to 8        :";A
270 N=A:LPRINT CHR$(27);"R";CHR$(N);
290 REM -----------------------------------------
300 INPUT "4.Set character width                                                           Pica=1,Elite=2,Condensed=3        :";B
320 N=B:LPRINT CHR$(27);"P";CHR$(N);
340 REM -----------------------------------------
350 INPUT "5.Set character style                                                            Normal=5,Italics=4               :";C
360 N=C+48:LPRINT CHR$(27);CHR$(N);
370 REM -----------------------------------------
380 REM *  Print zero with a slash  *
390 N=1:LPRINT CHR$(27);"V";CHR$(N);
400 REM -----------------------------------------
410 INPUT "6.Set character Emphasis                                                        Emphasize=1,Normal=2              :";E
420 N=E+68:LPRINT CHR$(27);CHR$(N);
430 REM -----------------------------------------
450 INPUT "7.Set double strike mode                                                        Double=1,Normal=2                 :";D
460 N=D+70:LPRINT CHR$(27);CHR$(N);
480 REM -----------------------------------------
490 INPUT "8.Set line spacing                                                              1/8=0,7/72=1,1/6=2,n/144=3        :";S
500 IF S=3 THEN GOTO 530
510 N=S+48:LPRINT CHR$(27);CHR$(N);
520 GOTO 550
530 INPUT "Enter value of n                  :";N
540 LPRINT CHR$(27);"3";CHR$(N);
550 REM -----------------------------------------
570 INPUT "9.Set script size                                                               Superscript=1,Subscript=2,Normal=3:";X
580 IF X=3 THEN GOTO 600
590 N=X+47:LPRINT CHR$(27);"S";CHR$(N);:GOTO 610
600 LPRINT CHR$(27);"T";
610 REM -----------------------------------------
620 INPUT "10.Set perf. skip Yes=1,No=2      :";PS
630 IF PS=1 THEN GOTO 650
640 IF PS=2 THEN GOTO 660
650 LS=10:LPRINT CHR$(27);"N";CHR$(LS);:GOTO 670
660 LPRINT CHR$(27);"O";
670 PRINT "Do you want a test :- Y/N         :";A$
680 A$=INKEY$
685 IF A$="Y" OR A$="y" THEN CLS:GOTO 730
690 IF A$="N" OR A$="n" THEN CLS:GOTO 800
695 IF A$<>"N" OR A$<>"n" OR A$<>"Y" OR A$<>"y" THEN GOTO 680
700 REM *****************************************
710 REM *            Test Message               *
720 REM *****************************************
730 FOR I=33 TO 126
740 LPRINT CHR$(I);" ";
750 NEXT I
760 FOR I=160 TO 255
770 LPRINT CHR$(I);" ";
780 NEXT I:LPRINT CHR$(10)
800 END

Barry

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Printer Commands
« Reply #7 on: April 08, 2013, 10:52:32 PM »
Yes you can do wonderful SLOW things with dot-matrix printers.
Control the dots one-by-one to drawGREAT hi-resolution 3-d images.
I used to write the progs one evening and view the pictures the next morning!

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Printer Commands
« Reply #8 on: April 09, 2013, 07:47:41 PM »
One day I hope to support printer escape codes in LPRINT.
As LPRINT is not setup to send data to a continuous paper feed printer like QBASIC was, I suggest 2 options:
1) Find some kind of DLL library and use DECLARE LIBRARY to call its commands or
2) Use _PRINTIMAGE. Remember QB64 images are all text-supporting surfaces, so you can PRINT to them (by using _DEST first). Do some searching for _PRINTIMAGE and you'll probably find some of my examples. _PRINTIMAGE is known to be very slow because it supports hi-res color printing as well, but it allows you to customize a lot of things, and you can use _PUTIMAGE to preview the content in your program first. Even though printing isn't supported on non-Windows platforms yet, I recommend _PRINTIMAGE for future compatibility reasons.

Happy to help more if I can.

***edit***
Check this out:
http://www.qb64.net/forum/index.php?topic=2596.msg21724#msg21724
(Works in QB64 GL too)
« Last Edit: April 09, 2013, 07:58:08 PM by Galleon »
Something old... Something new... Something borrowed... Something blue...

bobtheunplayer

  • Jr. Member
  • **
  • Posts: 70
  • I'd rather be coding.
    • Email
Re: Printer Commands
« Reply #9 on: April 09, 2013, 08:06:15 PM »
It has been my experience with laser printers that all the data needs to be shoved out one page at a time, so add all the content to the stringToPrint$ then drop one LPRINT stringToPrint$ this should be sufficient for building "expense" and other accounting related reports if you do not want to get fancy with fonts, line spacing, and whatnot.

  • Print