Silverfrost Forums

Welcome to our forums

Bug %pl / change_plot_chr@ /64 bit

19 Apr 2025 8:48 #32088

In the following program a very simple graph is plotted using %pl. To the right of the plot there is a button “NEXT”, whose call back calls change_plot_chr@ and simpleplot_redraw@ to change the y_axis label on the %pl graph. This works updating the plot as expected.

However, when the window is closed after the button “NEXT” has been clicked on, an unknown exception is generated. If the calls to the function change_plot_chr@ in the function next_y_cb are commented out (so that the change of label is not applied) the unknown exception is not generated.

I have observed this with the 64 bit compiler, the 32 bit compiler does not fail in this way. Similar failures can be observed for changing the x_axis label and the title of the plot – again only with the 64 bit compiler.

module test_change_plot_chr
use clrwin
implicit none 
integer :: plot_number = 1 
real*8 :: x(2) = [0,1], y(2) = [0,1]

contains

 integer function start()
 integer :: iw
   iw = winio@('%mn[Exit]&','exit')
   iw = winio@('%fn[Tahoma]%ts%bf&',1.5d0)
   call winop@('%pl[n_graphs=1,native,x_array]')
   call winop@('%pl[Title='A simple graph']')
   call winop@('%pl[yaxis='Frequency']')
   call winop@('%pl[xaxis=' X ']')
   iw = winio@('%pl&',900,600,2,x,y)
   iw = winio@('%^bn[Next Y]', next_y_cb)
   start = 2
 end function start

 integer function next_y_cb()
 integer i
   plot_number = plot_number + 1
   if (plot_number .gt. 2) plot_number = 1
   if (plot_number .eq. 1) then
     i = change_plot_chr@(0,'y_axis',0,'Sin(x)')
   else
     i = change_plot_chr@(0,'y_axis',0,'Cos(x)')
   end if
   print*, i
   call simpleplot_redraw@()
   next_y_cb = 2
 end function next_y_cb

end module test_change_plot_chr

program p
use test_change_plot_chr
i = start()
end program p
20 Apr 2025 8:30 #32089

Taking another look this morning I see I was mixing options %pl[y_axis] and %pl[yaxis] in the code above.

Using 'y_axis' only the following modified code still fails in the way I described above with the 64 bit compiler.

module test_change_plot_chr
use clrwin
implicit none 
integer :: plot_number = 1 
real*8 :: x(2) = [0,1], y(2) = [0,1]

contains

 integer function start()
 integer :: iw
   iw = winio@('%mn[Exit]&','exit')
   iw = winio@('%fn[Tahoma]%ts%bf&',1.5d0)
   call winop@('%pl[n_graphs=1,native,x_array]')
   call winop@('%pl[Title='A simple graph']')
   call winop@('%pl[y_axis='Frequency']')        !Change here
   call winop@('%pl[x_axis=' X ']')
   iw = winio@('%pl&',900,600,2,x,y)
   iw = winio@('%^bn[Next Y]', next_y_cb)
   start = 2
 end function start

 integer function next_y_cb()
 integer i
   plot_number = plot_number + 1
   if (plot_number .gt. 2) plot_number = 1
   if (plot_number .eq. 1) then
     i = change_plot_chr@(0,'y_axis',0,'Sin(x)')
   else
     i = change_plot_chr@(0,'y_axis',0,'Cos(x)')
   end if
   print*, i
   call simpleplot_redraw@()
   next_y_cb = 2
 end function next_y_cb

end module test_change_plot_chr

program p
use test_change_plot_chr
i = start()
end program p

Using 'yaxis' only in the code, I see that

i = change_plot_chr@(0,'yaxis',0,'Sin(x)')

fails (returning i =5) I did not expect this to work since 'yaxis' was added to the library after change_plot_chr@.

What I am trying to show in this second post is that the failure is not due to using

 call winop@('%pl[yaxis='Frequency']') 

before the graph is formed, followed by i = change_plot_chr@(0,'y_axis',0,'Sin(x)') in the callback.

The failure does not occur when using:

 i = change_plot_chr@(0,'y_axis',0,''Sin(x)'')

but the axis label becomes 'Sin(x)' instead of Sin(x)

21 Apr 2025 6:12 #32091

Ken

Thank you for the feedback. I have made a note that this needs investigating.

22 Apr 2025 7:48 #32093

This failure has now been fixed for the next release of the ClearWin+ library.

23 Apr 2025 1:21 #32094

Thank you Paul, it has taken me years to isolate this failure!

Please login to reply.