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 

Full_mouse_input with PL

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



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Jun 06, 2021 2:41 am    Post subject: Full_mouse_input with PL Reply with quote

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.

Code:
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


Last edited by DanRRight on Sun Jun 06, 2021 3:23 am; edited 1 time in total
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Jun 06, 2021 3:22 am    Post subject: Reply with quote

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

Code:
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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Jun 06, 2021 8:16 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Mon Jun 07, 2021 8:41 am    Post subject: Reply with quote

I have uploaded a new clearwin.ins and associated mod files. Please see http://forums.silverfrost.com/viewtopic.php?t=4245.

The documentation for GET_RGB_VALUE@ is incorrect. The HOR and VER values are INTEGER(KIND=2).
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Jun 07, 2021 4:01 pm    Post subject: Reply with quote

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 integer*4 and real*4 and D for real*8 Integer*8.

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.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Jun 07, 2021 5:58 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Jun 07, 2021 11:32 pm    Post subject: Reply with quote

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 INTEGER*4 were default even when this compiler was born as Salford FTN77. Using INTEGER*2 across this compiler library was clearly a design mistake which over 30 years generated rivers of tears and decibels of swearing
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jun 08, 2021 7:22 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
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