Silverfrost Forums

Welcome to our forums

Difference in handling of %cw across compilers

26 Feb 2018 9:23 #21523

The ClearWin code below behaves differently on two different compilers (ftn95 and gfortran). The ftn95 version works as expected (a new window is created for the initial prints / writes and the MDI child window captures subsequent writes).

Under gfortran, the prints / writes do not go anywhere. I can live without the first few prints creating a window, it is the %cw functionality I am trying to get working in a much larger programme. Unit 6 is stdout, but 120 has been tried as well with the same results on both.

They are both compiled using 64 bit ClearWin.

 PROGRAM main
      use clrwin$
      INTEGER*8 win, subwin
      integer winctrl

      print *, 'Output via print to default'
      WRITE (*,'(//''Output via write to default'')')

      i=winio$('%ww[no_border]&')
      i=winio$('%pv%fr&',400,300)
      i=winio$('%lw&',winctrl)
      i=winio$('%hw',win)

      i=winio$('%ww[no_border,no_maxbox]&')
      i=winio$('%ca[win caption]&')
      i=winio$('%aw&',winctrl)
      i=winio$('%pv%53.10cw[hscroll,vscroll]&',6)
      i=winio$('%hw',subwin)
      
      WRITE (*,'(//''Output to default via write - 2'')')
      WRITE (6,'(//''Redirected output to stdout/win via write'')')
      
      print *, 'win', win
      print *, 'subwin', subwin
      
 END

My question is, am I doing something wrong or is I/O redirection handled differently under non silverfrost compilers?

Apologies for the spammy looking image links.

The Ftn95 version looks like this when run; [img]https://1drv.ms/u/s!AukE8rFa04Mei80MmsJQ04O1-dJXuw[/img]

The gfortran version looks like this; [img]https://1drv.ms/u/s!AukE8rFa04Mei80NeHq_Rq57xmghLQ[/img]

The source code can be downloaded from: https://1drv.ms/u/s!AukE8rFa04Mei80OKkVDq9RtEtL-eQ

I can share the compiler arguments if needed.

Regards

Ryan[/code][/b]

27 Feb 2018 8:17 #21528

Ryan

%cw will only work with Silverfrost compilers. You could try using %re or %eb but off-hand I don't know the easiest way to append new lines.

8 Mar 2018 1:40 #21585

Understood. As a test I am trying to get %eb to work in Silverfrost 64 bit and I'm failing.

Similar to the above issue, the redirected output disappears but does not turn up in the edit buffer. This is for a Silverfrost executable. Compiling for gfortran yields a runtime error of 'Argument number 2 of WINIO@ (continuation 5) should be a 64 bit integer'.

The %lc call seems to be working (on silverfrost) and grabs the window handle of the edit buffer (confirmed with spyxx.exe).

PROGRAM main
      use clrwin$
      integer(kind=CW_HANDLE) win, subwin, editHandle
      integer winctrl
      INTEGER UNIT_STDOUT
      PARAMETER (UNIT_STDOUT =6)
      CHARACTER*1000 buffer

      print *, 'Output via print to default'
      WRITE (*,'(//''Output via write to default'')')

      i=winio$('%ww[no_border]&')
      i=winio$('%pv%fr&',400,300)
      i=winio$('%lw&',winctrl)
      i=winio$('%hw',win)

      i=winio$('%ww[no_border,no_maxbox]&')
      i=winio$('%ca[win caption]&')
      i=winio$('%aw&',winctrl)
      i=winio$('%pv%fr&',300,200)
      i=winio$('%53.10eb&',buffer,1000)
      i=winio$('%lc&',editHandle)
      i=winio$('%hw',subwin)

      call open_to_window$(UNIT_STDOUT,editHandle)

      WRITE (*,'(//''Output to default via write - 2'')')
      WRITE (6,'(//''Redirected output to stdout/win via write'')')
      
      print *, 'win', win
      print *, 'subwin', subwin
      print *, 'editHandle', editHandle
      
 END
8 Mar 2018 2:09 #21586

open_to_window$ is not related to %eb.

You could try writing to a string (internal WRITE) and then calling INSERT_EDIT_STRING@.

8 Mar 2018 5:51 #21593

My thinking on this was that %eb produced a standard Windows control from which I could get the handle and pass to open_to_window$ which accepts a standard windows handle.

Obviously there is something else going on there.

Please login to reply.