VOGONS


First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

For anyone who wants to print from DOSBox under OS X, I've prepared a workaround that makes it possible to do so, although it's a bit of a kludge.

Download the ZIP file in the link at the bottom of this post. Extract the folder action script (it's an application bundle, not a simple script) and move it your ~/Library/Folder Action Scripts folder. Then right-click on an OS X folder that is accessible from DOSBox because it is inside the folder that you mount in DOSBox - or, for the greatest flexibility, right-click on any folder that you mount as the root directory of a drive in DOSBox. From the contextual menu choose Setup Folder Actions or some similar name (depends on OS version), and attach DOSBoxPrinting to the folder.

Now start up DOSBox. The instructions below assume that you attached the folder action to C:\ (the root directory of the mounted C:\ drive), but it can be any other directory accessible to DOSBox.

If your application can print to a file, then do one of the following:

1. If your application supports PCL, then set the output printfile to something like C:\OUTPUT.PCL or any other filename in C:\ with a .PCL extension. (The folder action script contains a copy that I compiled of GhostPCL, which the script uses to convert PCL to PS, which is then printed by the lpr command to the default printer).

2. If your application supports PostScript, then set the output printfile to something like C:\OUTPUT.PS or any other filename in C:\ with a .PS extension. (The folder action script uses lpr to print the file to your default printer.)

3. If your application prints ASCII text output only, set the output printfile to something like C:\OUTPUT.TMP or any other filename in C:\ with a .TMP extension. (The folder action script uses lpr to print the file to your default printer.)

4. If your application prints ASCII text, but does NOT support printing to a file, then try this (which works with EDIT.COM). In the field in your application where you enter a printer port (LPT1, COM1, etc.), enter: C:\@
and you should be able to print. This works because the script automatically prints any text file named "@" to the default printer.

Further notes: The printfile is deleted after printing, but files that are NOT named *.PCL, *.PS, *.TMP, or @ are ignored by the script.

If you want to see exactly what the script does (a reasonable thing to want), open it in your Applescript Editor application to see the script, and right-click on it and choose Show Package Contents to see the enclosed files.

The script requires OS X 10.6 or later for PCL printing; if anyone wants it, I can replace it with a version that works with 10.4 or 10.5, but doesn't support "Dark Courier" as the 10.6+ version does.

Features not yet implemented (though I have these features working on a similar setup and can add them if anyone wants them):

1. The option to popup an OS X dialog in which you can select a printer. This would work by setting the output filename to "SELECT.PCL", "SELECT.PS", etc. I have this working on my WordPerfect for DOS under OS X system, and can add it here.

2. An option to print PCL directly to the default printer, if you know that the default printer supports PCL (like most HP LaserJets and laser printers from Brother, Canon, etc.). Again, I have this working on my WordPerfect system. The advantage of this is that all PCL commands in the original file get sent to the printer, including embedded PCL codes. In the existing system, these embedded codes get stripped out when the printer output is converted to PostScript before printing.

3. An option to create a PDF file in OS X from the PCL, PS, or text output files. Again, I have this working for PCL and PS on my WordPerfect system, and it would be easy to add support for text files.

Warning: if you want to print PCL output, you will need to have X11 software installed in OS X; under OS X 10.6 and 10.7, this is probably installed by default. Under 10.8 Mountain Lion, when it is released, you will need to install third-party X11 software; Mountain Lion itself will explain this when you try to print PCL output. X11 is not required for text or PostScript output.

The folder action script can be found here; this link will always link to the current version, and I'll post notices of any features that I might add.

https://dl.dropbox.com/u/271144/DOSBoxPrintingForOSX.zip

Last edited by emendelson on 2012-07-01, 02:24. Edited 2 times in total.

Reply 1 of 16, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Not eager to try this but sounds good and better than a special dosbox built. You might want to add this to the wiki 😉

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 2 of 16, by IIGS_User

User metadata
Rank Oldbie
Rank
Oldbie

Please set PDF support to the top of your changes list and keep the script running in the future. 😉

Klimawandel.

Reply 3 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

OK, I'll add PDF support in the next few days and will post a notification here.

Meanwhile, here's another thought: If your DOS application does not support printing to a file, you might try this (after making a backup copy of your DOS application!). Open the application in a hex editor; search for LPT1 or LPT1:. If you find either string, change LPT1 to C:\@ (replace C:\ with whichever drive letter matches the OS X folder to which you've attached the folder action script), or change LPT1: to C:\@ followed by a space character (or a null character, hex 00). Save the file, and try printing. It may work or it may not!

Reply 4 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Dominus wrote:

You might want to add this to the wiki ;)

Will do exactly that once I've added a few more features. (The puzzle of the wiki password is rather easy to solve...!)

Reply 5 of 16, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

(The puzzle of the wiki password is rather easy to solve...!)

Not too long ago we had someone almost troll here who really couldn'T figure this out 😀

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 6 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Question about PDF support:

I think I can implement both these methods of creating PDFs:

1. Create a PDF file on the desktop (or user folder) with the filename created from the current date and time (something like 201206251734.pdf)

2. Create a PDF as a temporary file that displays in Preview so that you'll need to save it from Preview to a file with a name that you choose.

Which one is preferable as the default? If I implement both, I can set a switch in the Applescript file so that the user can change the default setting.

Reply 7 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

OK, I've implemented additional features for this printing system:

First, follow the instructions in the first post in this thread, but with these additional details

1. To create PDF files from DOSbox, do the following.

If your DOS applicaiton supports PCL output, set the print output file to PCLTOPDF.PCL.

If your DOS application supports PostScript output, set the print output file to PSTOPDF.PS

If your DOS application supports only ASCII ouput, set the print output file to TEXT2PDF.TMP

The PDF files will appear on your desktop with arbitrary filenames based on the current date and time. An option in the AppleScript itself lets you change the output folder to your home folder; AppleScript experts will be able to set any other folder.

2. To select your OS X printer when printing from DOSBox, do the following:

If your DOS application supports PCL output, set the print output file to SELECT.PCL

If your DOS application supports PS output, set the print output file to SELECT.PS

If your DOS applications supports only ASCII output, set the print output file to SELECT.TMP

3. To print PCL output directly to your default OS X printer - if and only if that printer supports PCL - set the print output file to DIRECT.PCL

The download link is the same as in the first post. Please let me know of any problems.

Not yet implemented: Warning message to install X11 (required for PCL output) if no X11 is installed in OS X. Support for PCL in OS X 10.4 and 10.5 (and warning message if PCL printing is attempted in 10.4 or 10.5)

Reply 8 of 16, by IIGS_User

User metadata
Rank Oldbie
Rank
Oldbie

Arbitrary file names seems to be fine so far (also including Date and Time stamps).
Is there a way for the AppleScript to examine the name of the DOS game which is printing,
to set the printout file to a corresponding file name?

Klimawandel.

Reply 9 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
IIGS_User wrote:

Is there a way for the AppleScript to examine the name of the DOS game which is printing, to set the printout file to a corresponding file name?

Yes, it's a kludge but it will work. Here is one way to do it:

1. In DOSBox, create a batch file that does the following:

a. The batch file uses the ECHO command to write a file to the directory with the folder action script; the command would look like this:

echo Name of My Game > C:\GAMENAME.FIL

Of course, replace C:\ with whatever directory matches the OS X folder to which the folder action script is attached.

b. The batch file then runs your game.

c. After you close the game, the batch file deletes GAMENAME.FIL.

2. In the Folder Action Script, add code that tests for the existence of GAMENAME.FIL. If the script finds that file, it then opens the file for reading and uses the contents of the file as a variable; the variable can be used as all or part of the specific name for the output file, so that your output file will use the name of the game instead of the arbitrary date that I use now.

I do something very similar to this in my WordPerfect application - I write a text file that contains the name of the WordPerfect document, and uses that name to give a name to the PDF. I'll try to add a similar feature to this script, but if you're expert in Applescript, please feel free to do a better job than I would. I don't really know Applescript - I just throw lines of code into the editor and hope that some of them work - so I always hope that someone more expert than I am will work on these things. But I'm willing to do it myself because I already have something similar working.

This method would require some precautions - for example, your DOSBox autoexec.bat should always delete any stray GAMENAME.FIL that was left over from a previous session because the game crashed and the batch file couldn't complete.

Just out of curiosity: which game are you using? And I'm delighted that someone actually finds this useful! (I have a comparable setup, based on AutoIt, working under Windows for my WordPerfect-under-64-bit-Windows system, but it would take some work to make it work with any game or application, though I think I know how to do it.)

Reply 10 of 16, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

I think you should do the Windows version as well. People think they need printing support and your workaround saves them from special dosbox versions.

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 11 of 16, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

please don't, that would make even more people think that dosbox can be used to run applcations.

Water flows down the stream
How to ask questions the smart way!

Reply 12 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
Qbix wrote:

please don't, that would make even more people think that dosbox can be used to run applcations.

Perhaps I could put in a EULA that says "This application may be used only for printing from games, not for applications"...???

Actually, the real problem is that DOSBox is written too well and the devs are too skilled, so DOSBox can be used for purposes it wasn't intended for. If the devs were less expert and less intelligent, this problem would never have happened...

Reply 13 of 16, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie
IIGS_User wrote:

Is there a way for the AppleScript to examine the name of the DOS game which is printing, to set the printout file to a corresponding file name?

OK, this was easier than I thought. The current version of the folder action script works exactly the same way as the one I posted earlier, but with this addition:

In DOSBox, start your game with a batch file that looks like this (replace c:\ with the path to the folder to which the folder action script is attached):

echo My Old Game>c:\APP-ID.FIL
d:\pathto\myoldgame.exe params <-- the command that runs your game
del c:\APP-ID.FIL

If the folder action script finds a file named APP-ID.FIL in the folder that receives the print files, it reads the file and places the content of the file at the start of the PDF filename. So if APP-ID.FIL contains the string "My Old Game" (no quotes), then the PDF file produced by the folder action script will have a name like:

My Old Game 120626122932.pdf

If the folder action script does not find a file named APP-ID.FIL, it simply uses the filedate for the name of the file.

The script is very easy to edit if you want to change the output filename.

Please report any problems that you may find with this new version.

This very slightly slows down the script, so you can turn it off by changing a variable near the top of the Applescript.

Reply 14 of 16, by IIGS_User

User metadata
Rank Oldbie
Rank
Oldbie
emendelson wrote:

Just out of curiosity: which game are you using?

I must admit I've not tried your printing solution yet, because I currently don't use a game which offers printing. 😉

emendelson wrote:

Perhaps I could put in a EULA that says "This application may be used only for printing from games, not for applications"...???

Add also something like
"There is absolutely *no* official support for printing from within DOSBox, at no point, and never will be. Use this printing capability only if you really need it."

Klimawandel.

Reply 15 of 16, by Gene Wirchenko

User metadata
Rank Member
Rank
Member
emendelson wrote:
Qbix wrote:

please don't, that would make even more people think that dosbox can be used to run applcations.

Perhaps I could put in a EULA that says "This application may be used only for printing from games, not for applications"...???

Actually, the real problem is that DOSBox is written too well and the devs are too skilled, so DOSBox can be used for purposes it wasn't intended for. If the devs were less expert and less intelligent, this problem would never have happened...

Computers are general-purpose machines. That means that they can be used for many purposes.

Sincerely,

Gene Wirchenko

Reply 16 of 16, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

dosbox is not a general purpose emulator though. It's specificly geared towards games and has intentional shortcommings and imprecissions while emulating.

Water flows down the stream
How to ask questions the smart way!