?
Solved

Open cash drawer without printing text

Posted on 2002-06-01
10
Medium Priority
?
1,502 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 264 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 264 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 264 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

800 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