Open cash drawer without printing text

Hi there,

I am using a Star TSP 200-24 printer, Delphi 5.0 and Windows 98...

Now, I want to open the cash drawer which has been attached to the Star printer. The printer itself is connected to the LPT1 port.

If I am using the below-mentioned code, the cash drawer will open, but there will be printed some text too:

      AssignPrn(BonFile);
      Rewrite(BonFile);
      WriteLn(BonFile,Chr(7));
      CloseFile(BonFile);

In other words, this is not working the way I want.

For your information, the following example was provided by the Developers FAQ Document, shipped with the printer:

      Open printer.port for output as 1
      Print #1, Chr(7)
      Close 1

This example is for VB, so it doesn't work in Delphi.

Please help me!!

Thank you in advance.

RoosieDB
roosiedbAsked:
Who is Participating?
 
bruintjeConnect With a Mentor Commented:
Hi RoosieDB,

this sample will print also

Open printer.port for output as 1
Print #1, Chr(7)
Close 1

but then in VB

you needed no printing only to opent he cash drawer?

can't you try

AssignPrn(BonFile);
Rewrite(BonFile);
CloseFile(BonFile);

leaving the writeline out of it? can't test of course i got no cash drawer, and no printer :)

:O)Bruintje
0
 
kretzschmarCommented:
just a guess

AssignPrn(BonFile);
Rewrite(BonFile);
Write(BonFile,Chr(7));  //No WriteLn
CloseFile(BonFile);

0
 
roosiedbAuthor Commented:
Hi Bruintje (a Dutch name ??),

I will try your solution soon.
The Chr(7) is the bell character. So I am not sure if this is printing text... There was also some remark about the font. If I want to use special characters, I need the "Control" font before I send anything to the printer. I've already tried that, but if you have some more tips then please let me know.

Hi kretzschmar,

I've already tried the write-command (not writeln), this was not working. Sorry. Any more tips? Please let me know.

Thank you both in advance !!

RoosieDB
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
bruintjeCommented:
Hi RoosieDB,

you could check this long url

http://groups.google.com/groups?hl=nl&lr=&threadm=3be84868_2%40dnews&rnum=1&prev=/groups%3Fq%3Ddelphi%2Bprint%2Bcash%2Bdrawer%26hl%3Dnl%26lr%3D%26selm%3D3be84868_2%2540dnews%26rnum%3D1

guess there could be something in it that you could use

btw Bruintje is from Bruintje Beer, Dutch version of Rupert Bear

HAGD
:O)Bruintje
0
 
roosiedbAuthor Commented:
Hi Bruintje,

I will check the URL as soon as I get home.

Best regards,
RoosieDB
(= Dutch for "Van Roosmalen" from [city] Den Bosch)

P.S. Kretzschmar, I hope you will also provide me with some more info. This issue is very important for me to solve. Thank you in advance!!
0
 
magellanLSConnect With a Mentor Commented:
Hello!

Here is how I do it.

First you need a function to access system ports:

procedure SendToSysPorts( Port :Word; Cmnd :Byte); stdcall;
 asm
    mov dx,Port
    mov al,Cmnd
    out dx,al
end;

And Here is how to open the drawer:

SendToSysPorts($3BE,$07);
{first parameter is the port address}
{second parameter is the command to send}

If this dosent work then try replacing $3BE with  $37A,
Becuase LPT1 usually has an I/O  port for commands of $3BE or $37A


NOTE: all code above doesnt work with winxp/winnt/win2000. If you need it to work in winxp/winnt/win2000 just ask me.

Hope This helps! ;-)
0
 
ITugayConnect With a Mentor Commented:
Hi roosiedb,

there should be list of commands in the end of printer documentation.
Usually it looks something like ESC - sequence.

Some action:  1B 0C 14

Just print this sequence to the printer.
Write(#$1B, #$0C, #$14);

Take care about printer switches. Printer can emulate different set of commands, e.g. "Epson mode". Would be better to switch it to native mode, because command set can be differ for different mode emulations.

----
Igor.

PS: did you try VB sample, does it work for you?
0
 
roosiedbAuthor Commented:
dear magellanLS,

Just a quick question, to make sure I have attached the printer on the right port...

What hex-code do I need when I seem to have connect this printer on COM1, COM2, COM3 or COM4 ???

It's not working yet, so I am trying different things right now.

Thank you.
roosiedb
0
 
pnh73Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between bruintje, magellanLS and ITugay

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.