Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How can I print Form Feed?

onkelhotte
New Contributor II
2,809 Views

Hi there,

I want to insert a Form Feed commandin my text output for my printer. So I inserted a char(12) in my text, char(12) is Form Feed in the ASCII Table.

But my printer just prints a small square instead of a Form Feed. I looked in unicode and those crappy Windows Codepage as well, but char(12) is Form Feed everywhere.

Do I have to modify it somewhere, maybe in the open statement? Im using CVF6.6c.

Thanks in advance,
Markus

0 Kudos
8 Replies
greldak
Beginner
2,809 Views

I'd suggest loading your file into a hex editor and checking you are writing exactly what you think you are.

Check also you are writing 12 (decimal) or 0C (hex) and your printer driver handles these as you expect.

Are you copying the file to the printer port or using windows to print it - if the latter it will load an application - possibly wordpad, word or notepad and that may be stripping the codes out and print from that.

Another option would be to to write a Fortran format print file and use the correct value in column 1, then use an appropriate utility to print it

0 Kudos
anthonyrichards
New Contributor III
2,809 Views

I have just programmed

write(outlu,form) array
write(outlu,'(a1)') char(12)
write(outlu,form) array

writing an array to a file, a formfeed character and then the array again. Openeing the file in PFE32 editor shows the forfeed as a black rectangle. When I sent the file to the printer using the File...Print menu, it printed the array as shown and form feed worked, the array being repeated on the new page.


0 Kudos
Steven_L_Intel1
Employee
2,809 Views
How are you printing the file? Are you using Notepad, for example? It renders LF as a square box. If you want a new line, the Windows newline sequence is CR-LF. Remember that you're not just sending ASCII to the printer, the text is being rendered into a bitmap first.
0 Kudos
onkelhotte
New Contributor II
2,809 Views

Thanks for your help!

I was able to print the file correctly with the PFE32.
Viewing the file with a HEX Editor shows a 0C at the right position, so somehow Windows screws it up. So my university professor is right about Bill :-)

The file is a text output of calculation results. The user should be able to print these results but not necessarily from my program.

I will implement the open and disp='print' when the user wants to print the results today or tomorrow.

Have a nice day,
OnkelHotte

0 Kudos
greldak
Beginner
2,809 Views

OK what you need in this case is to change the default program windows is using to print.

In Windows Explorer go to the Tools Menu, Select Folder Options, then File Types, scroll down to the correct extension for your file and select it, click Advanced, select Print from the list of Actions and click Edit.

You will be presented with a dialog giving the command used to print the file - it probably uses Notepad. You need to change this to use an editor such as PFE32 which will handle form feed characters correctly. Note this will change how any files with that extension are handled so its probably best to use a unique extension.

0 Kudos
onkelhotte
New Contributor II
2,809 Views

I cannot say to our customers: "You have to use this editor to view and printtext files." They will think: "Oh god, he is not able to print a simple text file. So, how do I know that his programcalcalutes correctly?" So it should be possible with Notepad.

As a programmerI know that Windows screws up codepages and so on. My prof always says that programmers have to pay for Bills stupidity...

Is there a way to tell Windows that there is a form feed and nota square? I dont want to do ASCII Art :-)

Markus

0 Kudos
greldak
Beginner
2,809 Views

Your other options then will require some code changes - the simplest being to copy the file to the printer port rather than using the print command. This will work if the file is pure ASCII which I suspect yours is, however you will need to track the printer ports within the application rather than relying on Windows to handle it for you. I'm not sure how well this will work with network printers either but is an easy option for local printers.

The Windows preferred option would be to use the printer routines in Windows itself rather than trying to print a file which will use a user defined application to do so.

0 Kudos
Steven_L_Intel1
Employee
2,809 Views

I think you misunderstand the situation.Form Feed is not recognized as a control character by Notepad, which is used by default for printing text files.

I suggest that you look at the FORPRINT sample provided with CVF - it has a complete solution for doing Windows printing of text in Fortran, and you can do "new page" by use of Fortran carriage control. Opening the file DISP='PRINT' is not likely to do much for you - it assumes an LPT device printer than accepts ASCII text, rare nowadays.

0 Kudos
Reply