forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Associate a fortran unit with a printer

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Jul 12, 2008 5:50 pm    Post subject: Associate a fortran unit with a printer Reply with quote

What I would like to do is this:

IA = OPEN_PRINTER@ (IHANDLE)
CALL OPEN_TO_WINDOW@ (99,IHANDLE)

i.e. after opening a printer with OPEN_PRINTER@, I should like to write to it with ordinary formatted fortran write statements to unit 99. I can do graphics, because I can SELECT_GRAPHICS_OBJECT@ with the handle. I just can't do fortran text output.

If I open the printer from a call-back, I have a fortran unit number and so I can use fortran formatted output.

OPEN_TO_WINDOW@ only connects the unit to a clearwin window (as the manual says).

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jul 14, 2008 8:34 am    Post subject: Reply with quote

How is this different from using a standard Fortran OPEN statement followed by a formatted WRITE?
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Mon Jul 14, 2008 5:43 pm    Post subject: Reply with quote

Hi Paul,

There seem to be three routes to getting output to go to a file:

(1) As always in fortran, I can send formatted output to a file using WRITE statements after OPEN has been used to connect a given file name to a fortran unit number.

(2) If I use 'FILE_OPENW' as a standard callback to a button or menu, I get a file name. I then link between file name and unit number with an OPEN statement, after which WRITE works as expected.

(3) If I want to send straightforward fortran formatted output to a file, then I use GET_FILTERED_FILE@ to get a file selection window. Once the user has picked a file name, I can associate a fortran unit number to it using the OPEN statement. This route therefore duplicates the functionality of using the callback 'FILE_OPENW', but caters for a need to select a file to write to at a position in the program where there is no convenient menu item or button.

Sending output to a printer ought to have equivalents to the three ways of sending output to a file:

If I simply use OPEN followed by WRITE, then provided that I use FILE='PRN' in the open statement I can get Windows output (and yes, this surprised me) to the default printer but I don't get a printer selection window, and I simply get portrait or landscape and printer resolution as selected previously and set as the printer default. This seems to me to be the direct-to-printer analogue of the first method of outputting to file (Method 1 above).

There is an analogue to method (2), and this is to use a callback associated with a menu item or button. I am spoilt for choice, with 'PRINTER_OPEN', PRINTER_OPEN1' and the two versions each of 'HTML_ ...' and 'GPRINTER_ ...' (ellipsis means the boring repetition left out). Since the argument list includes a fortran unit number, (except for 'GPRINTER_ ... '), I now don't need an OPEN statement.

(Actually, I can't see the use for 'PRINTER_SELECT', but maybe that will come to me later).

However, if I use OPEN_PRINTER@, then I get the printer selection window, but once I have selected a printer, it isn't connected to a Fortran device number. I have a handle, but no fortran device. I can do graphics output to it, but not straightforward Fortran output. If you tell me that OPEN_PRINTER@ is intended ONLY for graphics output, then I will have to accept that. However, in that case, shouldn't it really be called OPEN_GPRINTER@ ?

What I wanted to do was to connect a given device number to the printer and its handle after invoking OPEN_PRINTER@. This would then be the direct-to-printer method analogous to method (3) above for sending output to a file. OPEN_TO_WIN@ does exactly the sort of thing that I want, but associates the handle of a clearwin window to a fortran unit number (and it doesn't work in connecting a printer handle to a fortran unit number).

It seemed to me that if there was no way of connecting a fortran unit to a printer opened with OPEN_PRINTER@, then maybe there ought to be one.

I think I'll go away and experiment with what sending output to 'PRN' does if a different printer has been selected; there are lots of functions such as SELECT_PRINTER@ that I don't fully understand.

Eddie
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Jul 15, 2008 4:39 am    Post subject: Reply with quote

Eddie,

I'm interested in your question, but probably do not have any solution.

I stopped printing to printers back in 1995, when HPGL got too complicated and it was easier to import .pcx files into word and print them.

I thought that printer control languages (pcl) have become too complicated to attempt and now resort to writing everything to file and then printing the file in word.

I understand that most of the printer control procedures are via winapi calls, so good luck.

Out of interest, what pcl are you using ?
Don't they provide for reset of page formats etc ?

Best of luck,
John
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Jul 15, 2008 2:59 pm    Post subject: Reply with quote

Hi John,

It's a lot simpler than you are imagining!

I have a collection of small fortran programs (topographic surveying routines) that I wrote in a hurry c. 1989 and which I have been assembling into a "toolkit" program. Some of the outputs are a picture, or one or two coordinates. They are easy to show on screen or to print - each routine giving a one-page output using only Clearwin graphics whether on screen or paper. No PCL used.

Two of the routines generate more than a page of tabulated output coordinates as well as a diagram, and eventually, the easiest way to do this on-screen was to make a window with a %cw field in it (using vscroll) and to just use fortran formatted write statements to send the tabulated results to the %cw field. For that, I needed to OPEN_TO_WIN@ to connect the Clearwin+ (%cw field) window to a particular fortran unit number.

The window with the %cw field in it has a "Print" button, and I could see myself servicing that with simply calling OPEN_PRINTER@, then associating a fortran unit with it, and then calling the routine that already has the WRITE statements in it. It was then that I discovered that there was no equivalent to OPEN_TO_WIN@ for printers.

As it happens, all I needed to do was put a callback on the Print button, and then I had the necessary connection.

Turning to what is implicit in your posting, do you not use the Clearwin graphics on output to Windows printers? If not, then you are missing some very nice facilities. There is virtually nothing that one needs from winapi - it's all in Clearwin. That goes for OPENGL output too.

The only thing I found rather a chore was getting exactly-scaled output, e.g. 1:500 scale maps, but in the end that wasn't too hard either.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group