Recent

Author Topic: using the printer  (Read 1284 times)

Lutz

  • Newbie
  • Posts: 4
using the printer
« on: January 29, 2025, 06:56:31 pm »
Hello pascal freeks, as a beginner I need a hint how to prepare my small program.
This version does not run:

program test;
uses printer;
begin
   write(lst,'Hello!');
end.

Is there a simple solotion without using canvas?

speter

  • Hero Member
  • *****
  • Posts: 522
Re: using the printer
« Reply #1 on: January 29, 2025, 11:39:52 pm »
If your program is a console application, it should write the message on the screen; it will NOT interact with the printer. Unless someone does it before me, I'll post a simple print msg project in a little while.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

speter

  • Hero Member
  • *****
  • Posts: 522
Re: using the printer
« Reply #2 on: January 30, 2025, 12:02:35 am »
Have a look at the attached (lazarus) project.

Note that it includes a printer dialog, which allows the user to set the printer etc.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Lutz

  • Newbie
  • Posts: 4
Re: using the printer
« Reply #3 on: January 30, 2025, 09:45:15 am »
Hello Speter,
many thanks to you. But I am searching for a more simpler routine for my console programs without any buttons, canvas, etc. There must exist a possibility like write(Lst,'Hello'); perhaps with asign(...,'C:/...)

Lutz

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: using the printer
« Reply #4 on: January 30, 2025, 09:54:31 am »
There must exist a possibility like write(Lst,'Hello'); perhaps with asign(...,'C:/...)
Sure. Which version of MS-Dos are you running and which brand dot matrix printer have you connected to your printer/parallel-port ?

Because code as you show/wish to use originates from that time-period and as such requires to have such technology connected to your computer.

PS: for the initiated, yes I know but I want to get a point across.
« Last Edit: January 30, 2025, 10:08:14 am by TRon »
Today is tomorrow's yesterday.

Lutz

  • Newbie
  • Posts: 4
Re: using the printer
« Reply #5 on: January 30, 2025, 06:00:32 pm »
Hello TRon,
I did not expect, that my simple question is so hard to answer.
My Computer is running with Windows 10, I do not know if there is a DOS behind it. I use a laser printer Brother MFC-L2710DW in my WLAN. 

Many thanks for your efforts.

PS In former times when I was young I had no troubles to send a string to the printer. Today under Windows it is much more complicated.

Lutz

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: using the printer
« Reply #6 on: January 30, 2025, 08:35:51 pm »
I did not expect, that my simple question is so hard to answer.
That is because 'they' made it complicated :)

Those days you are talking about are long gone. Though brother does refer to it on this page.
An excerpt:
Quote
To print from DOS, or any non-Windows application, your Brother device must emulate either PCL 4, 5, 6 and/or Brother's BR-Script (PostScript language emulation).
Refer to the specification of your Brother device to see if it supports these emulations.

Your DOS software must also include a printer driver for one of the emulations listed above. For example if you own a Brother HL-1450 printer and you wish to print from a DOS application, look for a HP Laserjet III or Laserjet 4 driver within your DOS software. These drivers will enable you to print at up to 600 x 600 dpi.

If there is no Laserjet III or Laserjet 4 driver - or your Brother device does not support PCL 5 or PCL 6, look for a Laserjet II driver.

Now, having quoted that, you have at least a real printer as in contradiction to a Windows only printer (these required that you run windows because without it you can't even print at all).

The 'problem' is that even when you are able to 'connect' to the printer by whatever means you would also have to communicate with with using the lingo that the printer understands. Sending ASCII is not one of them (anymore) unless your printer offers such a service with its drivers.

I, for example, have a similar printer like yours (other brand) that I have connected by USB and my printer offers the ability to send to it a PDF and it will print that PDF (I use linux (not Windows) which fortunately has provisions that makes it easier to access devices). But, also I cannot send my printer ASCII tokens by using a simple writeln.

Besides that you also have the printer connected via your network (instead of directly attached to the machine) which adds another layer of complexity.

That is one of the reason why this all became more complicated over the years. The supplied drivers take care of everything behind the scenes and which is done by using a standarized API which is part of the (graphical) OS.

Having said that, it is quite possible your printer manufacturer icw OS offers drivers that allow you to access the printer in the network by offering support for an old dos driver or by addressing its network name but that depends on the drivers which /might/ perhaps allow you to use a simple writeln.

Besides that your printer talks/offers a bunch of other protocols that are listed here under Supported Protocols and Security Features and which allows for other means of accessing and communicating with your printer.

Now, the main question becomes how to do that and the answer is that it completely depends what the printer offers and how you wish to proceed.

In these days and age a simple writeln isn't usually one of them and the example offered by speter is one of the easiest solutions (even though not exactly what you asked for). As a bonus speter's solution works cross-platform and for other printers while any other used method might not.

As an alternative you could consider 'printing' your output to a file (which can be done with a writeln) and (manually) use a GUI application that is capable of printing the output to your printer but is merely a simple suggestion in case you do not wish to spend time investing details of your printer.
« Last Edit: January 30, 2025, 08:43:57 pm by TRon »
Today is tomorrow's yesterday.

Lutz

  • Newbie
  • Posts: 4
Re: using the printer
« Reply #7 on: January 31, 2025, 09:05:20 am »
Hello TRon and SPeter,
you both did a great job for me and all the other Oldies who made the first experiences with Pascal in the 1980s. I will study your hints.

Thank you very much

Lutz

 

TinyPortal © 2005-2018