replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Off limits %~fl warning
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 

Off limits %~fl warning
Goto page 1, 2, 3, 4  Next
 
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: 2879
Location: South Pole, Antarctica

PostPosted: Sat May 08, 2021 10:18 pm    Post subject: Off limits %~fl warning Reply with quote

Paul,

We discussed this already and I think after some time you have mentioned somewhere last year that similar code like below now shows the warning red dot when code starts or when some other part of program will try to change the value of A to be out of limits (0-1 like in our case).
Code:
real*8 A
A=1.1
i=winio@('%~fl%rf%`fl',0d0, 1d0, A)
end

Unfortunately, the behavior is still the same: this dot only appears if you manually try to type value larger than 1.

Similar demo showing that if the code will try to change variable A with the value 1.1 no warning is appearing
Code:
real*8 A
common /aaaa/A
integer, external :: Run
 A=1.1
 i=winio@('%~fl%rf%`fl%ff&',0d0, 1d0, A)
 i=winio@('%^bt[Change A]%es', Run)
end

integer function Run()
 A=1.1
 call window_update@(A)
 Run=2
end function

The importance of showing warning is because %rf is used not only for manual entering the values but also when the code itself changing this variable i.e. doing opposite - writing - as if it will be used like with %wf if update A with "call window_update@(A)". As i wrote in this case though there is still no warning. %rf/%rd are even more convenient than %wf/%wd by the way. Latter ones i almost never use because it is out of style with %rf/%rd. To use %wf its background has to be changeable, but it is just gray.

We need such dynamically changed warnings ! For example i use warnings like changeable background under the number field, or the font color, or %si! and $si#, or popup windows. Otherwise it is easy to miss something wrong. Unfortunately it is not easy to do (need some efforts in the code) and some of these controls are not dynamically changeable.

For example %si! and %si# signs are very good to warn users but are not dynamically changeable to appear/disappear and not size changeable so i use their smaller visual analog instead, callable as a bitmap fitting into one text line i=winio@(' %bm[exclm_sm] Error!&'), see the example below. Though the size of image now is convenient for inline warnings, the appearance/disappearance is also not dynamically changeable. The %~fl would be great easiest way to get the warnings which do not require any additional efforts besides just adding one single sign of tilde to the code !!! Rozy background in the picture below by the way is also warning sign telling user to pay attention, this one i can dynamically update, but that requires 2-3 orders of magnitude more symbols to add to the code than just one tilde

Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon May 10, 2021 9:25 am    Post subject: Reply with quote

Dan

I am not clear about what you are asking for but the following sample may help.

1) In your code there is a missing "common /aaaa/A" in the function Run.

2) Maybe you should be using CONTROL_UPDATE@ rather than WINDOW_UPDATE@ (see cwplus.enh). It depends on what you want.

3) From the sample you can dig out a way to add your own icon that can be shown/hidden under program control. You will need to provide your own 16x16 icon.


Code:
winapp
program main
real*8 A
common /aaaa/A
integer, external :: Run,Switch
integer(7) hctrl
common /bbbb/hctrl
 A=1.1
 i=winio@('%~fl%rf%`fl&',0d0, 1d0, A)
 i=winio@('%ic[error]%lc&', hctrl)
 i=winio@('%sc&', Switch)
 i=winio@('%ff%^bt[Change A]%es', Run)
end

integer function Run()
 include <windows.ins>
 real*8 A
 common /aaaa/A
 integer,external::Switch
 A = 1.1
 call CONTROL_UPDATE@(A)
 i = Switch()
 Run = 2
end function

integer function Switch()
 include <windows.ins>
 logical, save:: show
 integer(7) hctrl
 integer ishow
 common /bbbb/hctrl
 logical L
 data show/.false./
 ishow = SW_HIDE
 if(show) ishow = SW_SHOW
 L = ShowWindow(hctrl, ishow)
 show = .not.show 
 Switch = 2
end function

resources
error ICON error.ico
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Tue May 11, 2021 5:30 am    Post subject: Reply with quote

Thanks, Paul, i have not got how you have done this trickery, but i will look twenty seventh time again Smile

My code indeed missed common block and also "use clearwin". When i added them and control_update@ which i did not know about i got this



If tilde %~fl will plot this image instead of red cross i still would use it (lazy or often no time to do perfect solutions) but something with red color would be move visible as warning Smile It is very simple to add 1 symbol to the text and is much better than do not have such functionality at all. Lost uncountable amount of days due to missing one small parameter in settings
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue May 11, 2021 8:33 am    Post subject: Reply with quote

Dan

I added the icon to the code in case the %~fl with CONTROL_UPDATE@ does not work in the way you want.

The following sample may do all that you want. If not then please describe the behaviour that you are looking for.

Code:
winapp
program main
real*8 A
common /aaaa/A
integer, external :: Run
 i=winio@('%~fl%rf%`fl&',0d0, 1d0, A)
 i=winio@('%ff%^bt[Change A]%es&', Run)
 i=winio@('%sc', Run)
end

integer function Run()
 include <windows.ins>
 real*8 A
 common /aaaa/A
 A = 1.1
 call CONTROL_UPDATE@(A)
 Run = 2
end function
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 730
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Tue May 11, 2021 10:57 am    Post subject: Reply with quote

I have not used CONTROL_UPDATE@. However, reading this post and the earlier discussion last year, at present:-

CONTROL_UPDATE@ behaves exactly like WINDOW_UPDATE@ but if the variable relates to %rd or %rf then any limits (%il or %fl) are not applied and any out-of-range alert icon (%~il or %~fl) is removed.

Perhaps what is required is:

CONTROL_UPDATE_SHOWERROR@ behaves exactly like WINDOW_UPDATE@ but if the variable relates to %rd or %rf then any limits (%il or %fl) are not applied and any out-of-range alert icon (%~il or %~fl) is not removed.

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Tue May 11, 2021 12:06 pm    Post subject: Reply with quote

Ken

I get more and more confused. We would then have 3 scenarios.

1) The user goes out of range so an error icon appears.

2) The programmer displays an out-of-range value without an error icon.

3) The programmer displays an out-of_range value with an error icon.

Maybe Dan's initial request (some time back) was for (3) and not (2).
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 730
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Tue May 11, 2021 12:48 pm    Post subject: Reply with quote

Paul,

Apologies for confusing you further, I was hoping to provide some clarity, but I failed.

In the first line of this post/topic Dan writes:

�you have mentioned somewhere last year that similar code like below now shows the warning red dot when code starts or when some other part of program will try to change the value of A to be out of limits�

So it looks like Dan�s initial request was for (3) and not (2).

Hopefully Dan will confirm.

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Tue May 11, 2021 1:18 pm    Post subject: Reply with quote

Ken

On the contrary, my confusion was not with your post. As usual your insight is welcome and valuable.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Tue May 11, 2021 7:52 pm    Post subject: Reply with quote

My request with tilde finctionality was simple : to keep all %il/%fl behavior like it was before and just to inform user with warning that there was an attempt to go out of limits not only when user doing that manually but at any other attempts the code made by itself

Again, let's keep all what was done (if manually change variable out of limits - make the red sign flashing) but just add that when the code itself changing variable out of limits to inform user too

It's like you come home and the smart door lock informs you that there was an attempt to robe your house which failed - this is manual way currently implemented. What i ask is that if somebody from the internet tried to unlock your lock remotely - inform me too Smile
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Tue May 11, 2021 9:08 pm    Post subject: Reply with quote

Paul, your code above is not showing any warning signs
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue May 11, 2021 9:31 pm    Post subject: Reply with quote

Dan

I might be getting near to understanding what you want. That is, a control with the limits applied but a warning icon appearing when an attempt is made to go beyond the limits. With the basic %fl, the feedback is that the control refuses to implement or corrects the change. You would like to have that but to accentuate the error with a warning flag. Presumably such a flag would have a limited time duration.

I don't know how that would work out in the ClearWin+ code but I will put it on the wish list.

Presumably the other context is when the user has provided the name of a data file and where this data contains values that are then displayed on screen. The data has been read in by the user but not directly by typing. Such values could be corrected to be within limits but marked with a warning icon to show the change.

Again I can put this on the wish list.

In my first sample above I have added elements of code for an icon that can be shown and hidden under program control. It could be made to flash by using a gif image instead of an icon. Perhaps one way forward would be for someone to develop those elements into one or two general purpose Fortran functions based on ClearWin+.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Wed May 12, 2021 7:34 am    Post subject: Reply with quote

Here is my first offering of what you might call ClearWin++ where the user adds their own functionality to standard ClearWin+. It is just a starter. At the moment it is not quite right and could be made more versatile (to allow many similar %rf controls). I have used %si for now.

Code:
module dmod
use mswin 
type rf
  real(2) lower,upper,val
  integer(7) hIcon
end type
type(rf)::x
contains

integer function rfcb()
  integer show
  logical L
  show = SW_HIDE
  if(x%val < x%lower)then
    x%val = x%lower
    show = SW_SHOW
  else if(x%val > x%upper)then
    x%val = x%upper
    show = SW_SHOW
  endif
  L = ShowWindow(x%hIcon,show)
  rfcb = 1
end function

subroutine winrf(x)
  type(rf)::x
  iw = winio@("%^rf&", x%val, rfcb)
  iw = winio@("%si#&")
  iw = winio@("%lc&", x%hIcon)
end subroutine

integer function change()
 x%val = 1.1d0
 change = rfcb()
end function
end module

winapp
program main
 use dmod
 x = rf(0.0d0,1.0d0,1.1d0,0)
 call winrf(x)
 iw = winio@("%ff%cn%^bt[Change]&", change)
 iw = winio@("%es&")
 iw = winio@("%sc", rfcb)
end program

Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Wed May 12, 2021 10:51 am    Post subject: Reply with quote

This sample illustrates how to make the above user adaptation available to multiple %rf controls. The extension is not trivial. It comes under the heading "no pain no gain". I will add a couple of 16x16 icons to ClearWin+ for use with or maybe instead of %si.
Code:
module dmod
use mswin
type rf
  real(2) val,lower,upper !val must be first to match "LATEST_VARIABLE"
  integer(7) hIcon
end type
type(rf),pointer::this
contains

integer function filter(x) !filter the %rf input and show/hide the icon.
  type(rf)::x
  integer show
  logical L
  show = SW_HIDE
  if(x%val < x%lower)then
    x%val = x%lower
    show = SW_SHOW
  else if(x%val > x%upper)then
    x%val = x%upper
    show = SW_SHOW
  endif
  L = ShowWindow(x%hIcon,show)
  filter = 1
end function

integer function rfcb()
  type(rf),allocatable::x
  integer(7) addr
  rfcb = 2
  if(clearwin_string@("CALLBACK_REASON")=="DATA_ALTERATION")then
    addr = clearwin_info@("LATEST_VARIABLE")
    allocate(x,absolute_address=addr)
    rfcb = filter(x)
  endif 
end function

subroutine winrf(x)
  type(rf)::x
  iw = winio@("%^rf&", x%val, rfcb)
  iw = winio@("%si#&")
  iw = winio@("%lc&", x%hIcon)
end subroutine

integer function reset()
 this%val = 1.5d0 !Test by changing to out-of-range value.
 reset = filter(this)
end function
end module

winapp
program main
 use dmod
 type(rf),target::x
 this=>x
 x = rf(0d0,0d0,1d0,0) !Initialise upper and lower.
 call winrf(x)         !User extension of %rf.
 iw = winio@("%ff%cn%^bt[Reset]&", reset)
 iw = winio@("%es&")
 iw = winio@("%sc", reset)
end program
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Wed May 12, 2021 2:37 pm    Post subject: Reply with quote

For the next release of ClearWin+ %si has been extended to provide 16x16 icons. %siX is an error icon, %siI is an information icon, %siQ is a question icon and %siW is a warning icon.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Wed May 12, 2021 6:18 pm    Post subject: Reply with quote

Thanks, interesting. We definitely need warning system in Clearwin to be versatile and convenient. Missed that from day 1 for a quarter of century

Question related to this: suppose we will need to make 100 %~fl%rf%`fl controls for 100 different variables.
Code:
i=winio@('Variable 1 %fl%rf%`fl&',A1)
i=winio@('Variable 2 %fl%rf%`fl&',A2)
.................

That will be total approximately 100 lines of user code.
Now using your examples above, which are about 50 lines long, do we need to write 100*50 = 5000 lines of code ? Or we need one 50 lines setup which will be used by each of our 100 variables, so the source code total length will be 50+100=150 lines ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
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