Solved

Open cash drawer without printing text

Posted on 2002-06-01
10
1,308 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:roosiedb
10 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 66 total points
ID: 7048752
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7048858
just a guess

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

0
 

Author Comment

by:roosiedb
ID: 7049299
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
 
LVL 44

Expert Comment

by:bruintje
ID: 7049334
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:roosiedb
ID: 7049378
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
 

Assisted Solution

by:magellanLS
magellanLS earned 66 total points
ID: 7049782
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
 
LVL 9

Assisted Solution

by:ITugay
ITugay earned 66 total points
ID: 7050300
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
 

Author Comment

by:roosiedb
ID: 7080449
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
 
LVL 1

Expert Comment

by:pnh73
ID: 9010417
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now