Link to home
Start Free TrialLog in
Avatar of cmajkrzak
cmajkrzakFlag for United States of America

asked on

Printer Communication in Filemaker 8-8.5


Currently I'm working with a Star TSP143 USB, and a standard cash drawer.  Currently I can use the print driver to open the cash drawer on print, but I need to find a way to open the cash drawer by Star's programming logic, rather then automatically by the driver. Example I want to print 4 seperate things, and open the cash drawer on the last print.  Now if I use the driver, it will trigger the cash drawer all 4 times.  Star lists the function to open the cash drawer as a hex 7 or dec 7, and gives the following VB code.

    StarComm1.StarComm_Output Text1.Text
    StarComm1.StarComm_Output Chr(7)

This obvisouly will only work with using Star's com object.  I need to be able to reproduce this functionality inside of Filemaker, and still maintain cross platform compatibility.  It would be possible to write a simple VB app and execute it to print, and/or use Apple script on the mac side of things to do the same thing, but I'm looking for away around writing external programs.  (VB Script on the pc, Apple script on the mac would be the most perfered method)

Avatar of Member_2_908359
Flag of France image

if it's only a matter to send dec7 to the printer port, this is a 1 line script which you can try manually by typing this in a shell window:
echo dec7 (use Alt7 to type it) > comX (X being the com port number where yr printer is hooked
same for osX, except that the printer port is a device, probably a name like /dev/lpr1 (I have no osX under my thumb now).
Orherwise, you can call a VB or Applescript from within filemaker without any problem.
Avatar of cmajkrzak


The problem with this would be that im trying to avoid calling an external VB program on the windows side, and I need to be able to speak to a usb printer, so directly "typing" to the printer really isn't an option for me. Ultimately I think I'd have to be able to talk to the windows spooler by printer name, which I think is pretty much impossible w/o some sort of small app to do it, such as VB or .NET (I know both enviroments, primarly C#, just trying to avoid calling extra programs).  I know its possible to work with the printers in OSX via Apple script I'm just completely unsure how to do this.

Avatar of billmercer

>Star lists the function to open the cash drawer as a hex 7 or dec 7

That's a control-G, or BEL character. It's intended to make a bell/beeper/buzzer go off on most ascii printers, so it makes sense to use it to open a cash drawer.

Just out of curiosity, have you actually tried inserting a ctrl-G into a Filemaker field and sending it to the printer? You may be able to do this with a line-mode driver, you might be able to use one of the generic Windows-provided Star drivers for this.


Bill, that would mean to install 2 drivers for the same device, and have one dedicated to open the drawer? Can be done under windows, but I can't see a way to do this under osX...
I've figured out how to do this on the mac via Apple scripts and some simple bash commands.  You use lp to actually send the command.  Example from within filemaker:

do shell script(\"echo " & FileContainingSymbolForOpenDrawer & " > ./open.txt\")
do shell script(\"lp -d " & PrinterName & " ./open.txt\")
do shell script(\"rm -f ./open.txt \")

This will create open.txt with the ^G needed symbol for opening the Star printer, execute lp with the printer name and the file to print and then delete the file.

With some testing this has proven to work very well.  Now on the PC side we don't have handy command line functions as we do in OSX with CUPS.  So the problem still exists on the PC where we need to send that command to the printer in a win32 enviroment, and probably using the spooler, as all we'll know is the printer name and the data that we need to send.  Doing some simple spooler calls from VB6, and sending Chr(7) does not seem to be doing the trick though :(
/ windows, you call a shell script too.
to print, you can either:
echo test > portname
type file.txt > portname
print file.txt > portname (via spooler)
 // port is lpt1
usb/sérial are comN ports
 so yr osX solution is feasable / windows in theory.
Let me know if you need help for this, and last Q: do you have a PC for testing? I can't test ,echo dec07 on my printer does nothing...
Yes, I indeed have have multiple PC's and Mac's that this can be tested on.  Even multiple star's and cash drawers if needed.  The biggest problem that I can think of at the moment, as I have to be able to do this on the pc side with only knowing the printer name.  From within Filemaker I really have no way of getting the "Port" the printer is on.  This solution has to basically be functional from using the printer's name or have some easy method of translating the name to a port.  (Unless you can think of a way of getting the port within filemaker).  Again I must repeat that all these printers are and will be strictly USB.

the print command can accept the printer name as argument:
PRINT [/D:device] [[drive:][path]file[...]]
where device is the windows name in your spooler, reported by filemaker with the proper get function.
I will test this shortly, and let you know how it works.

>print /d:"Star TSP700 Raster Printer with status monitor" .\open.txt

Unable to initialize device Star TSP700 Raster Printer with status monitor

Maybe I have the wrong syntax here?  open.txt is just a plain text file with the open drawer symbol in it.
Are you sure the printer is called "Star TSP700 Raster Printer with status monitor". I am suspicious about the "with monitor".
If yes, try a shorter name with no space, I am not sure print which is a legacy command appreciates sentences as names! It might not even consider double quotes
Star TSP700 Raster Printer with status monitor

Thats the exact name windows shows it from its propertise

I just tried shorting the name to "Star"

print /d:Star .\open.txt
Unable to initialize device Star

So it appears to be the same issue, no matter the name.
unfortunately true, I just checked the syntax in one of my old scripts, and it uses ... the port name! lptN or comN.
The only workaround I tested ok is to use a netbios path as the port name which the method for network printers.
But you can also share a printer to yourself!

To test: share the printer "Star TSP700 Raster Printer with status monitor" as PrinterX
and use:
print /D:\\PCname\PrinterX .\open.txt
where PCname if the netbios name of your PCon network.
>print /d:StarTSP7 .\open.txt
Unable to initialize device StarTSP7

Seems to be the same result.  Even though if this worked, it wouldn't be a good solution as getting a novice to share a printer, share it with a given name exact as the script calls over, and overall setup would just be a bit to hard.  I'm about 95% sure its going to require programming in VB6/C#.NET and a call from Filemaker to the given application to do it.  But even doing this, problems arise because theres no way of directly written to a given port, because we're on USB.
the syntax you mention is not for a shared printer: must be /D:\\pcname\shared_printer_name
ok, true, not for regular users.
another hairy method: get the portname from the registry.
Using some command line utility like the ones in the NT dev resource kit, you can read the portname if you know the windows name from the registry.
One thing to note here, that I guess is a bit of a help, pc name can be subbed for the loopback.
print /d:\\\\StarTSP7 open.txt

Still rather avoid having to share the printer ideally.  I've got an e-mail in with Star about the windows spooler side, Ill see if they might have a suggestion with there own examples.  The one thing I've noticed, while this does reproduce what works on the mac, for some odd reason it does kick a bunch of paper out when this command is sent.  Almost like its doing a full page feed, which I'd guess is certianly possible since this is using a standard spooler.
the sheet which is kicked out is probably because of the CR/LF at the end of your text file which is automatically added when you create it, while unix/osX only puts CR. Check the file with a binary editor (like XVI32) to confirm, or move the PC file to osX and send it to the printer.
btw, lpr does exist /windows, it seems to take the windows printer name... but you need to install lpd first which is probably a drawback for you.
anyway I hope Star has a command line utility, maintenance tool or something which can help.
XVI32 shows only one character in the file Dec(7) like it should be.  So I'm still a bit confused as to why its doing what looks like a full page feed.  Almost like if you were to print a single line in a text editor, yet the 8.5 x 11 printer would still need to feed the rest of the page out.
Form feed added by the spooler automatically? DOS print command was behaving like that...
does it do it if you echo dec(7) > comN ?
Again the printer is USB, but even so I tried echo dec(7) > USB001, no errors, but no results either.
sorry... only bluetooth ports can emulate com ports.
no real fix though... Can refound his points?
Well... for me the answer is that there is no way to do what he wanted...
But PAQ - refund is also ok..
Avatar of DarthMod
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial