Silverfrost Forums

Welcome to our forums

Hello ClearWin+

17 Jan 2011 11:28 #7514

One way is o use a button to call a print function

           i=winio@('%^bt[ Hard copy output  ]&','PRINTER_OPEN',7,Print_func


         integer function print_func()

          write(7,*)' '
          write(7,*)' '
          write(7,90)
 90     format(5x,80('-'))
          write(7,91)
 91     format(20x,'Program Name  Demo print output')
          write(7,90)
          write(7,*)' '
         write(7,*)'                            Run on ',edate@(),' at ',time@()

etc
etc


          close (7)
         print_func=2

         end

This calls the standard windows printer dialog. The information that you want to print needs to be made available to the function (eg via a common statement)

Cheers

17 Jan 2011 12:48 #7518

Thanks! This is really easy 😄

Instead of setting the unit equal to 7 I tried a variable (write(ou,*)) - would like to control wheter it goes to the screen or printer. Using the code below I found that ou in (1;2;5;6) will cause the data to be written to the screen instead of a file.

Question: Are these unit numbers (1;2;5;6) default (or rather reserved) for the screen?

program cutandpaste

integer :: ou,io_err

do ou=0,20
  write(ou,'(I4,A)',IOSTAT=io_err) ou,'  Successful'
  if (io_err>0) then
    write(*,'(I4,A)') ou,'  does not work'
  endif
enddo
end
19 Jan 2011 2:47 #7552

If your output always has a physical meaning (e.g. I see you have 'torque' and 'bore diameter' which look physical to me) why not draw a picture of it, with dimensions, arrows etc. Then make optional output (a) graphical, (b) textual. Users tend to prefer (a) over (b).

After decades of sending printouts to a page printer, line printer or character-by-character printer or to a file, I now find the pictures more concise and easier to read, besides which, they create less waste. Even if you have to print a picture, the total number of pages to print and store should be less.

A picture is worth a thousand words!

Eddie

19 Jan 2011 3:27 #7554

Eddie, I agree with the idea of a picture. However, since I am at the beginning of exploring the possibilities ClearWin+ has to offer it will take another while 😄

Another advantage of a picture is that one has a visual test of e.g. the machine dimensions (in our case). Often this leads to much quicker results than by evaluating the 'text numbers'.

In a previous thread I got some very useful tipps how to handle pictures! However, handles in ClearWin+ are a still a black box to me.

19 Jan 2011 10:12 #7561

Back in June 2009 I started a thread called 'When is a handle not a handle', to which Paul added some useful notes. (And I put it in Suggestions accidentally). Sometimes you give a handle, sometimes you get a handle. To know which, you have to read FTN95.CHM [u:93e9cf3e59]VERY[/u:93e9cf3e59] carefully!

Eddie

20 Jan 2011 10:11 #7567

Eddie, thanks for the tipp on the handle thread.

I am making good progress in using the FTN95.CHM. However, if I look at the following example winapp integer :: i,winio@ external cb_help i=winio@('%ww&') i=winio@('%mn[Help]',cb_help) end

integer function cb_help()
  integer i,winio@
  i=winio@('%ca[About Number Factoriser]&')
  i=winio@('%fn[Times New Roman]%ts%bf%cnTutorial&',2.0D0)
  i=winio@('%2nl%cn%9`bt[OK]')
  cb_help=1
  return
end

I must have two handles when the help window appears. In this case (I assume) that ClearWin+ automatically takes care that only the help is active. If I would like to override this situation I need the do something with the window handles. A simple example would do the thing - if someone can point me to that in the documentation. As soon as I press OK the main window is active again.

[URL=http://img109.imageshack.us/i/helpig.png/]http://img109.imageshack.us/img109/4684/helpig.png[/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

20 Jan 2011 4:10 #7585

The About box as programmed is modal - nothing else in the program is clickable, including the other windows, while this is on the screen. Other programs are accessible. Sure, the About box does have a handle, but it is hidden from you, because you have not provided a variable for it to be given to you. Actually, other things have handles (Windows handles that is) including the OK button. Again, you don't need to know those handles, and you haven't any way of accessing them.

Now with the way that the About box is shown, the only way to shut it is with the Close box (red cross, top right on the caption bar) OR the OK button. If you press the red cross, WINIO@ returns 0, if you press the button, WINIO@ returns 1. In neither case do you care about these values: the About box (window) will just disappear, and you will return control to the window it was called from. Sometimes you are concerned how the user exited the Window, and you can test the value returned (it is in the variable IA (say) as in

IA = WINIO@ ('   format codes  ')

for the last WINIO@ call in the sequence.

If you want to have the (windows) handle to a window, then use %hw to give it to you, and provide an integer to hold it - the handle is an integer. If you want the (windows) handle for the OK button, then use %lc to send it to you, and again provide an integer to hold it.

If you used 16-bit Windows, you will remember the 'shortage of resources' messages. This was because the total number of unique 16-bit numbers available for handles was small. In 32-bit windows the total number is large.

If you repeatedly open and close the About box, Windows will generate and discard handles for it (and for the OK button). Each time, it is possible the numbers (handle values) are different.

These handles are Windows handles. For this use, you do not need to know what any of the handles are.

If you want to give the About box a life of its own, then use %lw (leave window) and provide an integer variable to control the window. THis is NOT a handle. However, if you change the value of the variable, then you can force the Window to close. This does mean that the particular variable needs to be in COMMON (etc) so that you can change its value when you want to shut the Window.

Note that although the buttons can have callbacks, the Close box cannot have a callback defined through WINIO@. A callback allows you to keep the window open after a button has been pressed, or close it after the callback code has been executed. The only way to do something similar for the Close box is to have a %cc code (which ALWAYS has its own callback) - or use %`cc which is similar but subtly different.

Eddie

20 Jan 2011 4:19 #7586

I forgot. A very useful thing in an About box is an image. One of the images you can use is a 'standard icon', which you get by using the %si format code. If you have moved on from Windows XP, then stylistically this goes on the left of the About box, with text to the right. Maybe it is worth using %ob ... %cb to get these lined up, and because you don't want to see the boxes, make them %ob[invisible]. In XP and before, the standard icon goes on the top usually. I suppose this reflects the general move from 4:3 aspect ratio screens to 16:10 or 16:9 wide screens.

Of course, you can draw your own bitmap, reflecting your firm's logo, or the program branding. Perhaps this is a little advanced!

Eddie

Please login to reply.