Silverfrost Forums

Welcome to our forums

Full_mouse_input with PL

6 Jun 2021 1:41 (Edited: 6 Jun 2021 2:23) #27896

Did i forget to declare something in this code where i tried to get RGB value at mouse pointer? My code has millions of Clearwin commands, but every time i try to add something new my previous experience does not matter at all. Like many of us (remember, Eddie?) slowly i start swearing and then yelling. Crashes and access violations is the only way Fortran exposes its errors. Added some Clearwin option - crash. Removed - crash, tried this - crash, tried that - crash, oh, may be this is the reason - crash, or that - crash. How it worked before? Taking older code - also crash? Impossible! Looked at HELP, added one more option - still crash, crash, crash.

use clrwin
integer, external :: SnapshotPL, mouse_RGB2
parameter (N=6)
real*8 X(N), Y(N)
Data X/1., 1e1, 1e2, 1e3,  1e4, 1e5/
Data Y/0.01, 10.2, 1266, 8333, 2111, 77/

i=winio@('%ww%pv%^pl[file=DDrates.set,title='D-D fusion',x_axis='Energy (keV)', &
& y_axis='Fusion crs',x_array,scale=log_log,n_graphs=1,y_min=1.e-2,y_max=1.e4, &
&full_mouse_input]&', 480,360, n, X, Y, mouse_RGB2)
i=winio@('%ff%cn%^tt[Snapshot]%es', SnapshotPL)
end

!----------------------------------------------
!   __  ___                    ___  ________ 
!  /  |/  /__  __ ________    / _ \/ ___/ _ )
! / /|_/ / _ \/ // (_-< -_)  / , _/ (_ / _  |
!/_/  /_/\___/\_,_/___|__/__/_/|_|\___/____/ 
!                       /___/      
!------------------------------------------
      integer*4 function mouse_RGB2()        
        use clrwin

        ix_mouse     = clearwin_info@('graphics_mouse_x')
        iy_mouse     = clearwin_info@('graphics_mouse_y')
        iflag_mouse  = clearwin_info@('graphics_mouse_flags')

!       call get_mouse_info@(ix_mouse, iy_mouse, iflag_mouse)

	call GET_RGB_VALUE@( ix_mouse, iy_mouse, iRGBvalue )

	ir256 = and (iRGBvalue,255)
	ig256 = and (rs(iRGBvalue,8),255)
	ib256 = rs  (iRGBvalue,16)

	print*,'ir256 ...', ir256, ig256, ib256

	mouse_RGB2 = 2
	end function

!......................................................
!   ____  __ _   __   ____  ____  _  _   __   ____
!  / ___)(  ( \ / _\ (  _ \/ ___)/ )( \ /  \ (_  _)
!  \___ \/    //    \ ) __/\___ \) __ ((  O )  )( 
!  (____/\_)__)\_/\_/(__)  (____/\_)(_/ \__/  (__)
!......................................................
! http://patorjk.com/software/taag/#p=display&h=2&v=0&f=Doh&t=Snapshot

  integer function SnapshotPL ()
  use clrwin

   character  PNGfilename*256, chdate*8, chtime*10, chzone*5
   integer ivalues(8)

   call DATE_AND_TIME(chdate, chtime, chzone, ivalues ) ! chdate format 20210504
   PNGfilename = 'zDesignerPL_'//chdate(1:8)//'_'//chtime(1:6)//'.png'
       
        i = export_image@(trim(PNGfilename))

        call sound@(3000,1)
        call sound@(1000,1)
        call sound@(2000,1)


    SnapshotPL = 2
  end function
6 Jun 2021 2:22 #27897

OK, let's get back to %GR where i have 100 examples of working code. Made small demo and it also crashing. Devilry. Hates me specifically on Saturdays. Some squiggle is missing somewhere and the Clearwin keeps mum what the hell it needs. Thinking that i will write the program in half an hour i not only failed but lost entire day furious

Without library of 1000 working snippets and users reporting the bugs or bad and good experience with Clearwin, it will never be popular and always cause pain in the butt

use clrwin
integer, external :: mouse_RGB2

i=winio@('%ww%pv%^gr[full_mouse_input,user_resize,box_selection]&', 480,360, mouse_RGB2)
i=winio@('%ff%cn%tt[Ok]%es')
end

!---------------------------------------------------------------
      integer*4 function mouse_RGB2()        
        use clrwin

!        ix_mouse     = clearwin_info@('graphics_mouse_x')
!        iy_mouse     = clearwin_info@('graphics_mouse_y')
!        iflag_mouse = clearwin_info@('graphics_mouse_flags')

        call get_mouse_info@(ix_mouse, iy_mouse, iflags)

	call GET_RGB_VALUE@( ix_mouse, iy_mouse, iRGBvalue )

	ir256 = and (iRGBvalue,255)
	ig256 = and (rs(iRGBvalue,8),255)
	ib256 = rs  (iRGBvalue,16)

	print*,'ir256 ...', ir256, ig256, ib256


	mouse_RGB2 = 2
	end function
6 Jun 2021 7:16 #27898

Dan

I am sorry that this has caused so much hassle.

Your sample reveals a regression in ClearWin+ and you will need a new clrwin.mod which I will aim to upload tomorrow.

In the interface for GET_RGB_VALUE@, the first two arguments should be of type REF2 and not VAL2.

Your sample will not work with the current clrwin.mod, even if you copy these arguments to INTEGER*2 values.

7 Jun 2021 7:41 #27901

I have uploaded a new clearwin.ins and associated mod files. Please see https://forums.silverfrost.com/Forum/Topic/3780.

The documentation for GET_RGB_VALUE@ is incorrect. The HOR and VER values are INTEGER(KIND=2).

7 Jun 2021 3:01 #27902

Paul,

Integer*2 is always invitation for disaster. Crashes were common in the times of DOS but currently considered as a sign of not robust tool.

How about following convention of OpenGL which is not less complex than Clearwin and where i never had a single crash related to syntax. I mean to introduce functions ending with F for integer4 and real4 and D for real8 Integer8.

In Clearwin case functions with Integer*2 arguments have to end with number 2

100% people will be 100% confused and surprised that it is integer 2 not a default INTEGER type. I was confused 100 times. Even today i found errors in the older code, not mentioning the error in the demos above

Or the FTN95 itself has to issue compilation ERROR if user takes wrong INTEGER type on the Silverfrost-specific functions, i see no reason it never did like that from 1980th, as they are not a Standard Fortran anyway

Thanks for the fix.

7 Jun 2021 4:58 #27903

This routine is very old. It dates back to a time when it was normal to use 16 bit integers where possible. The default integer type has been 32 bits for many years.

In this case you will find that it is OK to use 32 bit integer values, although you will get a warning from the compiler.

7 Jun 2021 10:32 #27905

If using INTEGER*4 works, then it's ok.

I do not know how people are not using or not often using GET_RGB_VALUE@. This has to be standard function declared by the Fortran Standard not less important than LOG or EXP...

I think INTEGER4 were default even when this compiler was born as Salford FTN77. Using INTEGER2 across this compiler library was clearly a design mistake which over 30 years generated rivers of tears and decibels of swearing

8 Jun 2021 6:22 #27908

Dan

I think that you are mistaken. We still see code that uses OPTIONS(INTL) which implies that there was a time when 16 bits was the default. I wasn't involved at the time but I think that there was a mainframe Salford Fortran compiler before 32 bit FTN77. And then there was also the need in the early days to integrate with Windows 95. Window NT came later.

Please login to reply.