joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.65k stars 376 forks source link

NewViews (nv.exe) fails to open files with Error 255 #2176

Open ezathashim opened 3 years ago

ezathashim commented 3 years ago

Describe the bug I am trying to use dosbox-x (0.83.9) on macOS Catalina and Big Sur for an old accounting program named NewViews. When I try to open accounting files, the NewViews app gives an error 255 and cannot open the books.

I thought it was just a general problem, but when I tried the same thing using regular DOSBox, it all works fine. I would prefer to use dosbos-x, particularly for the ease of use and printing functions.

I can send a copy of the app and a sample book to open, if anyone is interested in looking into this issue.

Thanks!

Wengier commented 3 years ago

Thanks for reporting the issue! Yes, please send a copy of the app and a sample book to open so that we can look at. I appreciate your support!

ezathashim commented 3 years ago

Great! Attached is a folder with the app and instructions.

Thanks!

Wengier commented 3 years ago

@ezathashim Thanks for uploading the files. So it is the usual "Packed file is corrupt" error, but DOSBox-X automatically fixes it only when the program is launched from the shell, not when from another application. But you can easily solve this by executing either command before running NV:

LOADFIX /A

Or:

A20GATE OFF

By the way, since you are running a text-mode DOS application, you probably want to check out DOSBox-X's TrueType font (TTF) output which will hopefully make the screen font look better than before. Either start with the config option "output=ttf" or select the output from the menu ("Video" => "Output" => "TrueType font"). More information about this output can be found from:

https://dosbox-x.com/wiki/Guide%3AUsing-TrueType-font-output-in-DOSBox%E2%80%90X.html

Hope this helps.

ezathashim commented 3 years ago

Wow, great!

Can this be entered in the config file somehow, or does the A20GATE OFF always need to be entered at the prompt?

rderooy commented 3 years ago

You can put the commands in the config in the [autoexec] section

Alternatively, for the A20gate, you can set a20=off in the [dosbox] section

ezathashim commented 3 years ago

Awesome!

Last thing - I've gone through the printing options in the configs, and there is no output on the Mac. Is there a wiki page on printing on the Mac that I cannot find?

rderooy commented 3 years ago

There is a wiki page on printing. My suggestion would be to use the print to PostScript feature and then print the PostScipt file afterwards.

If you have any suggested updates to the wiki specific to macOS, let us know. I personally do not have any macOS systems.

ezathashim commented 3 years ago

Ok, I got it to work on my Mac with the following modifications in the config file:

[parallel] parallel2 = printer (my DOS application is set to use LPT2)

[printer] printoutput = ps multipage = true docpath = /Users/username/Documents/DOSBox-X_Output

I tried modifying the docpath with a '~/Documents/...' format and it did not seem to work. With the config default docpath setting, the output is saved to the root of the user Home folder (/Users/username), which was a bit confusing since the wiki states it should go to the currently active folder.

There is also a bug in the output system when using the Mac. The output file cannot be opened until I shut down DOSBox, so maybe there is a missing line of code to release the file at the end of the output? If you try to open it before quitting DOSBox-X, there is an error 'The PostScript file “doc1.ps” could not be converted to a PDF file.' This bug also seems to prevent pushing the file to the Mac print system. Should I post a new issue concerning this?

I'm really excited to have this app in my hands and the fact that it already runs on M1. Can I contribute a new Icon that will look better on our modern screens? I could probably take the existing one and give it more resolution.

rderooy commented 3 years ago

Could you try from the DOS menu the "Send form-feed" option?

Regarding the icon, there is a SVG icon that is used on Linux. But I'm guessing that is not the icon that is getting used on macOS.

ezathashim commented 3 years ago

With the following config:

multipage = true docpath = /Users/username/Documents/DOSBox-X_Output

If I print from the DOS app, no file is produced at the designated path UNTIL I select the 'Send Form-Feed' menu item, at which point it is generated and I can open the file. I noticed the notes in the config file after you mentioned it. I'm not sure what happened earlier, but I was getting a .ps file even before the CTRL+F2 was pressed.

Thanks very much! It's an incredible piece of work that I wish I could contribute to.

rderooy commented 3 years ago

If you look at the timeout value on the wiki, that may explain what happens. By default, it waits until it receives a form-feed to close the file, unless you set a timeout value. DOSBox-X does not know when the DOS application is done printing.

You may also want to look at redirecting the print output on the wiki. This way you can have it automatically open an application when the file is closed.

ezathashim commented 3 years ago

This is really awesome - so much better than running a VM!

I would maybe suggest putting this info more explicitly on the wiki printing section; you have been a real help.

rderooy commented 3 years ago

Sure the wiki can be enhanced. What application do you use on macOS to open postscript files? I can add it to the wiki, if you can give me the syntax.

ezathashim commented 3 years ago

On macOS, everyone uses Preview for this purpose. However, I tried adding 'openwith = Preview' to the config file and it gives an error:

"The requested file handler failed to complete." CleanShot 2021-01-10 at 12 35 34@2x

I suspect it has to do with allowing the app to open the file automatically. There are Security settings that need to be toggled on macOS to allow apps to do such things. Do you know what command it used to open the file?

rderooy commented 3 years ago

If in a terminal you type

Preview <filename>

Does it open the file in the Preview application?

ezathashim commented 3 years ago

No, it does not. In Terminal, you would need this command:

open -s "Preview" filename

for example:

open -s "Preview" /Users/usename/Documents/nv/Printouts/myDocument.ps

ezathashim commented 3 years ago

So if I have this setting in [printer]:

openwith = open -s "Preview"

it works!

rderooy commented 3 years ago

In that case, try something like:

parallel1 = file file:output1.ps timeout:1000 openps:"open -s Preview"

Or create a batch file with something like

open -s "Preview" %1

save it as openps.sh, set it executable, then call the batchfile with

parallel1 = file file:output1.ps timeout:1000 openps:openps.sh
ezathashim commented 3 years ago

This command did not work and gave a "The requested file printing handler failed to complete." failure error:

parallel1 = file file:output1.ps timeout:1000 openps:"open -s Preview"

I think 'openwith = open -s "Preview"' is a better and less complex solution for mortals to understand.

Do you want me to write up a 'Mac' section to add to the wiki?

rderooy commented 3 years ago

@ezathashim sure, feel free to write a mac section.

ezathashim commented 3 years ago

I think the command:

parallel1 = file file:output1.ps timeout:1000 openps:"open -s Preview"

did not work because you need the " around Preview, as in "Preview". Is there a way to properly escape the enclosed " in something like this:

parallel1 = file file:output1.ps timeout:1000 openps:"open -s "Preview""

rderooy commented 3 years ago

No, but you can try 'open -s "Preview"'

So use single-quote for the outer quotes and double quote for the inner.

Wengier commented 3 years ago

You can use single quotes for outer quotes and double quote for the inner, but you will need to have the squote option enabled, e.g.

parallel1 = file file:output1.ps timeout:1000 squote openps:'open -s "Preview"'

ezathashim commented 3 years ago

It failed as well.

I'll write up something and send it to you later today.

Thanks!

Wengier commented 3 years ago

@ezathashim Did you put the squote option?

ezathashim commented 3 years ago

Yes, I just tried again and it failed. It was a copy-paste.

Also, it places the file in the top level of the home directory, which is not ideal.

Wengier commented 3 years ago

@ezathashim I probably mistyped a single quote symbol when I first posted it, so if you just do a copy-paste if may not work. But I just want to let you know the existence of such an option, in case you need it.

Wengier commented 3 years ago

@ezathashim The output file is placed in the current working directory if you do not specify a path, so if the current working directory is the home directory then it will be placed there. If you want it to be placed in a different path, then just explicitly specify a path for that. Hope this helps.

ezathashim commented 3 years ago

Gotcha. I triple checked the parallel1 = file:... and it really does not want to play ball.

Attached is my take on macOS and DOSBox.

Thanks for all your help! DOSBox-X macOS Instructions.txt

ezathashim commented 3 years ago

Made a slight tweak DOSBox-X macOS Instructions.txt

rderooy commented 3 years ago

Actually, the tilde resolving to your home directory (or relative paths in general) is a feature of the shell. On Linux this would be for instance the bash shell.

For DOSBox-X to support the tilde in the config file for an entry, special care needs to be taken to expand it to the full path as the base libraries used to open files do not support a tilde. In some places DOSBox-X already supports this. For instance in the mount command.

e.g. this works:

mount c ~/dosroot
ezathashim commented 3 years ago

Ok, here is an updated document. Maybe the config file interpreter should have the ability to interpret tilde paths. One annoying thing is having to copy path strings in the various areas of the config file. Perhaps a special [paths] section could be used to create a path string that can be used elsewhere in the file, and this section could have the ability to resolve tilde paths. DOSBox-X macOS Instructions.txt

Wengier commented 3 years ago

@ezathashim Can you make a list of options in the config file need to be interpret tilde paths? I think perhaps they can actually be improved to do so. (for Windows systems, environment variables in such options will be expanded instead)

ezathashim commented 3 years ago

Sure - I'll have something for you tonight.

rderooy commented 3 years ago

I will hold with updating the wiki for the moment.

ezathashim commented 3 years ago

The only areas that I can see that can take a path are:

[parallel] [printer] [autoexec]

I only looked at the smaller config file, not the complete one. Do you want me to look at the complete one?

ezathashim commented 3 years ago

[parallel] for file: [printer] docpath [printer] fontpath [autoexec] for mount [config] set path [render] glshader: [gus] ultradir

More complete

Wengier commented 3 years ago

@ezathashim Thanks for making the list! It is certainly helpful. But please note that [autoexec] and [config] section commands only have access to the drives inside DOSBox-X, but not host system drives, so options in these two sections are probably not quite applicable. In any case, I have already added support for file path expansion for printing and serial/parallel port file options in #2183. For Windows systems, environment variables in such options will be expanded, and in non-Windows systems the tildes will be expanded. glshader and ultradir have additional requirements so they will be handled later.

rderooy commented 3 years ago

Actually, there are a few more places

[sdl] mapperfile mapperfile_sdl1 mapperfile_sdl2

[log] logfile

[dosbox] language savefile

[render] pixelshader

[midi] midiconfig mt32.romdir fluid.soundfont

[serial] file, openwith, openerror phonebookfile

Wengier commented 3 years ago

@rderooy Thanks! Hopefully all of the places you mentioned (as well as glshader and ultradir) will now be resolved in #2186, in addition to the places already resolved in #2183.

rderooy commented 3 years ago

Nice! that will certainly be appreciated by Linux and macOS users alike.

ezathashim commented 3 years ago

In case you want to do one last thing for Mac, attached is an .icns file that can be used for the Mac icon file. It is based on the Linux svg file.

Many thanks!

hardl1 commented 2 years ago

@rderooy I read your comments with interest. I've been trying to print from a Clipper program for days. On a macbook in a windows VM this worked without any problems with DOSBox-SVN. The error "The requested file handler could not be completed." always occurs when the control character e.g. ??[CHR(27)+"(s0h12V"] is sent in the Clipper program in single-step mode. All changes to the quotation marks ([ ' ") have so far been unsuccessful. Do you have any idea?

ezathashim commented 2 years ago

I’m not familiar with Clipper, but from my notes, I have this:

***

Of note, modifying [parallel] with this sort of entry will not work:

parallel1 = file file:output1.ps timeout:1000 squote openps:'open -s "Preview”'

There appears to be an issue with resolving the double-quotes that are required to tell macOS to use Preview. You could,        however, elect to open the file using the default application in this way:

parallel1 = file file:/Users/username/Documents/targetFolder/output1.ps timeout:1000 openps:”open”

***

I’m not sure what your setup is, but maybe you should try the technique outlined above.

I have attached the instructions file that I have archived.

On Aug 9, 2022, at 11:31 AM, hardl1 @.***> wrote:

@rderooy https://github.com/rderooy I read your comments with interest. I've been trying to print from a Clipper program for days. On a macbook in a windows VM this worked without any problems with DOSBox-SVN. The error "The requested file handler could not be completed." always occurs when the control character e.g. ??[CHR(27)+"(s0h12V"] is sent in the Clipper program in single-step mode. All changes to the quotation marks ([ ' ") have so far been unsuccessful. Do you have any idea?

— Reply to this email directly, view it on GitHub https://github.com/joncampbell123/dosbox-x/issues/2176#issuecomment-1209535602, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABI7U5YWSGB7ILAYQUKDU4DVYJ2T5ANCNFSM4V3PVUBQ. You are receiving this because you were mentioned.

Specifics for Macintosh OS

Macintosh has peculiarities with regards to file paths and launching programs to open the print output. Paths on Macintosh using the tilde (~) can be resolved by the OS to the true file path. For example:

~/Documents

would resolve to:

/Users/username/Documents

The DOS system resolves the tilde differently, and so cannot be used in most areas of the DOSBox-X config file. The DOSBox-X Shell, however, can resolve tilde in paths, so commands like 'mount' are able to use this convention.

Opening files using Terminal commands is done by this command:

open -s "Preview” filepath

Opening a file using the default OS application is done with this command:

open filepath

A typical setup might be the following:

  1. Determine the 'targetFolder' on the filesystem that you wish to represent as the C: drive and add this to the bottom of the config file:

mount c /Users/username/Documents/targetFolder in [autoexec]

This will automatically mount the 'targetFolder' on DOSBox-X launch. Because 'mount' is a shell command, this would also work:

mount c ~/Documents/targetFolder in [autoexec]

  1. If you are using a text-based, then you might want to use TrueType fonts with this setting example:

ttf.ptsize = 30 in [render] output = ttf in [sdl]

  1. For the printer settings, determine the LPT port the application uses and enter something like this:

parallel1 = printer in [parallel]

  1. Print output setting are determined by the [printer] section of the config file. On Macintosh, Postscript is a great output with these sort of settings:

printoutput = ps in [printer] docpath = /Users/username/Documents/targetFolder/Printouts in [printer] openwith = open -s "Preview” in [printer] timeout = 1000’ in [printer]

In the above example, the output will be saved to a 'Printouts' subfolder found in 'targetFolder'. If this entry is not made, then the output will default to the root level of the user home folder. The file will be opened by the 'Preview' application using the 'openwith' entry. The timeout parameter is needed to avoid having to press CTRL+F2 to tell the system that the output is complete.

Of note, modifying [parallel] with this sort of entry will not work:

parallel1 = file file:output1.ps timeout:1000 squote openps:'open -s "Preview”'

There appears to be an issue with resolving the double-quotes that are required to tell macOS to use Preview. You could, however, elect to open the file using the default application in this way:

parallel1 = file file:/Users/username/Documents/targetFolder/output1.ps timeout:1000 openps:"open"

hardl1 commented 2 years ago

Thanks Ezat, I have already tested this configuration, unfortunately without success.

rderooy commented 2 years ago

Personally, I would not suggest to use parallel1=printer, unless the DOS application only supports Epson or IBM Pro Printer. If you have the choice, use the parallel = file file:output1.ps... syntax and configure a PostScript printer in the DOS application. Or alternatively, you can try a HP LaserJet using the PCL language, but I don't know if macOS understands PCL files by default.

The Epson printer emulation, which is enabled with parallel1=printer is not great. The output is pretty ugly, and the fact that higher DPI settings don't work with the emulated printer does not help.

hardl1 commented 2 years ago

My problem seems to be related to the clipper program. I wrote it myself 20 years ago, but only with control sequences for PCL and ESC. It is a pure text program for house cost accounting. Unfortunately, I have no experience with control characters for PS, so I need a Clipper example. However, it is unclear to me why the PCL control characters work in the same program in the Windows VM under Dosbox-SVN, but are simply ignored under Dosbox-X and appear as a printout.

ezathashim commented 2 years ago

Could you try replacing the control character with a Mac-centric numeric equivalent? I think you would enter a backslash like this:

In C, Objective-C and C++, "\001" is a string containing a single Control-A character. '\001' would be a single Control-A character; you might as well write 1 (without quotes around it).

I found it here:

https://forums.macrumors.com/threads/entering-control-characters.782792/

On Aug 11, 2022, at 5:01 AM, hardl1 @.***> wrote:

 My problem seems to be related to the clipper program. I wrote it myself 20 years ago, but only with control sequences for PCL and ESC. It is a pure text program for house cost accounting. Unfortunately, I have no experience with control characters for PS, so I need a Clipper example. However, it is unclear to me why the PCL control characters work in the same program in the Windows VM under Dosbox-SVN, but are simply ignored under Dosbox-X and appear as a printout.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

hardl1 commented 2 years ago

@ezathashim Unfortunately, I can't get any further with control characters like '\xxx'. I also tested emendelson's DOSBox-X app and scripts, but the app doesn't work for me. I've also asked for help on the XBase/Clipper forums, but to no avail.

hardl1 commented 2 years ago

@ezathashim But I think the instruction http://www.columbia.edu/~em36/printfileprinter.html refers only to Windows. My problem only exists with MacOS on M1.