Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to send a character directly to the paralel port

Status
Not open for further replies.

poderosocarlos

Programmer
Jul 7, 2003
2
MX
I'm working with a Point of Sales program... the printer is an Epson TM-U200 and the ticket is in Qreport... well the problem is that I need to send a special character to the printer if I want to open the cash drawer, and I don't know a command or instruction that can send a letter (in hex) directly to the paralel port.
 
Heres some code i used to send printer control codes to a print and apply printer:

Code:
var
    port, prnfile: file;
    buffer: array[1..128] of Char;
    Read: Integer;
    tempfile: string;  //the name of the file 
          
//... do some stuff, creating stringlists and saving to file with printer codes
                //NOW SEND THE FILE TO PRINTER PORT
            AssignFile(prnfile, tempfile);
            Reset(prnfile, 1);
            // specify printer port
            AssignFile(port, LPT1);
            Rewrite(port, 1);
            repeat
                BlockRead(prnfile, buffer, SizeOf(buffer), Read);
                BlockWrite(port, buffer, Read);
            until EOF(prnfile) or (Read <> SizeOf(buffer));

thats the general gyst of it anyway.. turns out quite easy
 
oops forgot some...

procedure TForm1.Button1Click(Sender: TObject);
var
port, prnfile: file;
buffer: array [1..128] of Char;
Read: Integer;
begin
// Specify a file to print
AssignFile(prnfile, 'filetoprint');
Reset(prnfile, 1);
// specify printer port
AssignFile(port, 'LPT1');
Rewrite(port, 1);
repeat
BlockRead(prnfile, buffer, SizeOf(buffer), Read);
BlockWrite(port, buffer, Read);
// Application.ProcessMessages;
until EOF(prnfile) or (Read <> SizeOf(buffer));
CloseFile(prnfile);
CloseFile(port);
end;


this was taken from
 
here are some simple example to send char to printer


var
ctxtFile : TextFile
begin
AssignFile(ctxtFile,'LPT1');
ReWrite (ctxtFile );
Writeln (ctxtFile,'The character you want to send');
end;
 
Well I have solve the problem... with the Epson MTU200 printer series, download the Windows driver of the printer, then when you install it... there will be installed a few new fonts, there is one named &quot;Control&quot;, well, when you send an A with this font to the printer it will open the cash drawer, this works anywhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top