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 

Dynamic backgrounds, font colors and warning signs
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Jul 21, 2020 1:30 pm    Post subject: Reply with quote

Well, not for me, but perhaps for others who like to program that way (if you forgive my attempts at humour). Such things are always useful because it lets people program 'their way' - a strength of FTN95. Perhaps it would be useful for Dan.

Eddie
Back to top
View user's profile Send private message
Kenneth_Smith



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

PostPosted: Tue Jul 21, 2020 2:40 pm    Post subject: Reply with quote

Paul,

I was unaware of SET_INTEGER_LIMITS@ until I read your last post, and then I discovered SET_FLOAT_LIMITS@ looking at the help files.

Is there a function to change step size e.g. for %df, to allow the user to switch from a large to a small step? I looked at this before and came to the conclusion is was not possible, but I may have overlooked something - again.

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


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

PostPosted: Tue Jul 21, 2020 3:42 pm    Post subject: Reply with quote

Ken

There is no such function at the moment but it could be added.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Tue Jul 21, 2020 7:05 pm    Post subject: Reply with quote

Paul,

Despite %rf by sense was meant for reading floating point numbers, is not used always just for input. Quite opposite, it is convenient to use %rf for output too with call window_update@. The controls for writing %wd and %wf I find very inconvenient and never use them. They are also out of style with other controls: they do not have the same frame like %rf controls have making GUI ugly. Besides %~fl does not work on %wf
Code:
real*8 a
a=2
i=winio@('%es%~fl%rf%ff&', 0d0, 1d0, a)
i=winio@('%`bg[gray]%~fl%wf', 0d0, 1d0, a)
end


So I use %rf for output. This makes %rf universal: I can load some variable, and computer like a robot can do the same. Some variables often serve not just for input purposes but both input and output, so this is natural to do that with %rf and %rd. In this sense it is not intended for computer to check such variables before displaying and restrict them like you have suggested. The %~fl with the tilde has to do that restriction as it does with as usual with %fl but it always has to display the warning sign (red dot) that the variable limits were broken, isn't it ?

So the code above has to show variable as 2 with red dot or 1 with red dot but not 1 without red dot as if nothing wrong happened !!!! The %~fl with tilde makes behavior of older %fl without tilde a bit logically different: with tilde the %~fl%rf has to show real value of a not restricted by 0-1 limit like %fl without tilde !



If %wf would react on %~fl accordingly and had the frame like %rf the problem would be solved too

Eddie
With a little bit different context than you asked for Paul, to not forget what the limits are as well as what this variable is used for (human memory is not made out of rubber and the codes tend to grow larger than a decent size city phonebook) i use ? sign with prompt: %?rf[variable a, limits 0 to 1].
Code:
real*8 a
a=2
i=winio@('%es%~fl%?rf[This is variable a. Limits = 0 - 1]%ff&',0d0,1d0, a)
i=winio@('%`bg[gray]%~fl%wf&',  0d0,1d0, a)
i=winio@('%th',1)
end


And %th used only ones for many controls. You definitely know this nice trick. Just mentioning it to those who do not know.


Last edited by DanRRight on Wed Jul 22, 2020 9:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jul 22, 2020 8:57 am    Post subject: Reply with quote

Ken

I have added the following function for the next release...

Code:
          DOUBLE PRECISION SET_INCREMENT@(hwnd,increment)
          INTEGER(7) hwnd
          DOUBLE PRECISION increment


hwnd is the Windows handle of the control obtained using %lc. The function returns the old value. It can also be used for %dd.

Dan

This sounds rather tricky but I will make a note to investigate the possibility of adding a special routine that provides what you want.

By the way, in response to your earlier comment, %pl now has the option [file=fileName] as an alternative to [params]. For example:

Code:
CALL winop@("%pl[file=plot.dat]")
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



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

PostPosted: Wed Jul 22, 2020 12:53 pm    Post subject: Reply with quote

Thanks for that Paul. I was preparing a simple example of where I thought this might be useful, in interactive vector/phasor diagrams before I saw your response.
Code:
winapp
module test_step
use clrwin
implicit none
integer,       parameter :: dp = kind(1.d0), cirnpts =361
real(kind=dp), parameter :: pi = 4.d0*atan(1.d0)
real(kind=dp), parameter :: deg2rad = pi/180.d0
real(kind=dp), parameter :: eps = epsilon(1.d0)
integer :: pl_npts(4) = [cirnpts,2,1,2]
real(kind=dp) :: mag=0.5d0, mag_max=1.5d0, mag_min=-1.5d0, mag_step=0.1d0
real(kind=dp) :: a =0.d0, a_max=360.d0, a_min=-360.d0, a_step=0.2d0
real(kind=dp) :: pl_x1(2) = [0.d0, 0.5d0], pl_y1(2) = [0.d0,eps]
real(kind=dp) :: pl_x0(1:cirnpts), pl_y0(1:cirnpts)
real(kind=dp) :: pl_xe(2) = [-1.d0,1.d0], pl_ye(2) = [-1.d0,1.d0]
contains
   integer function gui_cb()
   integer i
   integer, save :: iw
   real(kind=dp) theta
     do i = 1, cirnpts, 1
       theta = deg2rad*dble(i) ; pl_x0(i) = cos(theta) ; pl_y0(i) = sin(theta)
     end do
     iw = winio@('%mn[Exit]&', 'exit')
     iw = winio@('%fn[Consolas]&')
     iw = winio@('%ts&',1.2d0)
     iw = winio@('%2.1ob[scored]&')
     iw = winio@('Magnitude [pu]%~fl%df%ta%6^rf&', mag_min, mag_max, mag_step, mag, update_cb)
     iw = winio@('%nlAngle [deg]%~fl%df%2ta%6^rf%cb&', a_min, a_max, a_step, a, update_cb)
     call winop@('%pl[native,independent,x_array,n_graphs=4]')
     call winop@('%pl[smoothing=4,margin=60,width=3,x-axis=@,y-axis=@]')
     call winop@('%pl[colour=grey, link=lines,symbol=0,symbol_size=4,pen_style=1]')
     call winop@('%pl[colour=black,link=lines,symbol=0,symbol_size=4,pen_style=0]')
     call winop@('%pl[colour=black,link=lines,symbol=6,symbol_size=4,pen_style=0]')
     call winop@('%pl[colour=white,link=none, symbol=10,symbol_size=1,pen_style=0]')
     iw = winio@('%ts&',2.d0)
     iw = winio@('%pl&',600,600,pl_npts,pl_x0,pl_y0, &
                                        pl_x1,pl_y1, &
                                        pl_x1(2),pl_y1(2), &
                                        pl_xe, pl_ye)
     iw = winio@('%cb')
     gui_cb = 2
   end function gui_cb

   integer function update_cb()
   real(kind=dp) theta, xmax, xmin, ymax, ymin
     theta    = deg2rad*a
     pl_x1(2) = mag*cos(theta) ; pl_y1(2) = mag*sin(theta)
     if (abs(pl_x1(2)).lt. eps) pl_x1(2) = eps
     if (abs(pl_y1(2)).lt. eps) pl_y1(2) = eps
     xmax = max(1.d0,maxval(pl_x1))
     xmin = min(-1.d0,minval(pl_x1))
     ymax = max(1.d0,maxval(pl_y1))
     ymin = min(-1.d0,minval(pl_y1))
     pl_xe(1) = max(abs(xmax),abs(xmin),abs(ymax),abs(ymin)) ; pl_xe(2) = - pl_xe(1)
     pl_ye(1) = pl_xe(1) ; pl_ye(2) = - pl_ye(1)
     call simpleplot_redraw@()
     update_cb = 2
   end function update_cb
end module test_step

program main
use test_step, only : gui_cb
implicit none
integer i
  i = gui_cb()
end program main
Back to top
View user's profile Send private message Visit poster's website
DanRRight



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

PostPosted: Wed Jul 22, 2020 9:16 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
By the way, in response to your earlier comment, %pl now has the option [file=fileName] as an alternative to [params]. For example:
Code:
CALL winop@("%pl[file=plot.dat]")

Waiting to test this great addition to native %PL which will make it so easy and pleasant to use!
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Nov 21, 2020 4:30 pm    Post subject: Reply with quote

DanRRight

In response to your request concerning changing %rf data under program control. a new routine CONTROL_UPDATE@ has been added for a future release of the DLLs (after v8.70).

Here is an outline description and example...

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.

Code:
winapp
program main
integer iw,winio@
double precision x
common x
integer,external::cb
x = 442.0d0
iw = winio@("%~fl&",1d0,256d0)
iw = winio@("Input:  %12rf&",x)
iw = winio@("  Result: %`12rf&",x)
iw = winio@("%ff&")
iw = winio@("%ff%nl%cn%^bt[Change]", cb)
end program

integer function cb()
include <clearwin.ins>
double precision x
common x
x = 400.0d0
call control_update@(x)
cb = 2
end function
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Sun Nov 22, 2020 5:43 am    Post subject: Reply with quote

Thanks, Paul.
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 Previous  1, 2
Page 2 of 2

 
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