Silverfrost Forums

Welcome to our forums

How to change %il upper limit while program running?

1 Feb 2009 11:14 #4268

Hi, I'm stumped on this one. How can I change the upper limit of %il when the program is running? I borrowed one of Paul Laidler's programs and modified it to show what I mean. Anyone any ideas?

Best regards

Albert

IMPLICIT NONE INCLUDE <WINDOWS.INS>

external line, changeupperlim integer*4 j,ii, upperlim

common /intern/ ii, upperlim

upperlim = 100 ii = 10

! j = winio@('%ca[Line]%sc%cc%gr[rgb_colours]%ff%dd%il%^4rd', !* line,'EXIT',200,200,1L,10,10,200,ii,line) ! j = winio@ ('%ca[Wilfred Line Test]&') ! Caption for window j = winio@ ('%sy[3d_thin]&') ! select windows 95 style edge j = winio@ ('%sc&', line) ! provide a call-back on startup j = winio@ ('%cc&', 'EXIT') ! provide a call-back when closed ?? j = winio@ ('%gr[rgb_colours]&amp;', 200,200,1) ! create a graphics window and provide handle j = winio@ ('%fn[MS SANS SERIF]&amp;') ! select a font for text j = winio@ ('%ts&amp;',.9D0) ! scale font to 90% normal size j = winio@ ('%ff&amp;') ! form feed j = winio@ ('%dd&amp;', 10) ! insert a spin wheel j = winio@ ('%il&amp;', 10,upperlim) ! select integer limit from 10 to integer upperlim j = winio@ ('%^4rd&', ii, line) ! read only control j = winio@ ('%^bt[change upperlimit]', changeupperlim) end

INTEGER FUNCTION LINE()

IMPLICIT NONE INCLUDE <WINDOWS.INS>

integer*4 ii

common /intern/ ii

call clear_screen@() call draw_line@ (1,1,ii,ii,1)

line = 1 end

INTEGER FUNCTION changeupperlim()

IMPLICIT NONE INCLUDE <WINDOWS.INS> integer*4 ii, upperlim common /intern/ upperlim

upperlim = 200 call window_update@(upperlim)

changeupperlim = 1 end

2 Feb 2009 2:29 #4271

The limits are fixed when the control is created. I think that I could add a function to change the limits dynamically but perhaps not in time for the next release.

In the mean time it is necessary to avoid using %il etc and to provide your own callback that applies the limits.

2 Feb 2009 2:33 #4272

Thanks Paul, I will look into a workaround.

Regards

Albert

2 Feb 2009 3:07 #4275

so work around is easy, but it isn't obvious to me why ii has to be declared in the function changelim? If I take it out it doesn't function properly anymore.

winapp
IMPLICIT NONE
INCLUDE <WINDOWS.INS>

external lim,changelim
integer*4 j,ii,ul 

common /intern/ ii, ul

ii = 10
ul=100

j = winio@ ('%ca[Wilfred Line Test]&')            ! Caption for window
j = winio@ ('%sy[3d_thin]&')                      ! select windows 95 style edge
j = winio@ ('%cc&', 'EXIT')                       ! provide a call-back when closed  ??
j = winio@ ('%`gr[rgb_colours]&', 200,200,1)      ! create a graphics window and provide handle
j = winio@ ('%fn[MS SANS SERIF]&')                ! select a font for text
j = winio@ ('%ts&',.9D0)                          ! scale font to 90% normal size
j = winio@ ('%ff&')                               ! form feed
j = winio@ ('%dd&', 10)                           ! insert a spin wheel
j = winio@ ('%^`4rd&', ii ,lim)                   ! read only control
j = winio@ ('%^bt[change upperlimit]', changelim) ! changes upper limit of spin wheel
end



INTEGER FUNCTION lim()

IMPLICIT NONE
INCLUDE <WINDOWS.INS> 
integer*4  ii, ul
common /intern/ ii, ul
if(ii>ul)then
 ii = ul
endif

if(ii<0)then
 ii = 0
endif
call window_update@(ii)
call clear_screen@()
call draw_line@ (1,1,ii,ii,1)
lim = 1
end

INTEGER FUNCTION changelim()

IMPLICIT NONE
INCLUDE <WINDOWS.INS> 
integer*4   ul,ii
common /intern/ ii, ul  ! why does ii have to be here for it to work?

if(ul==200)then !switching upperlimit of spinwheel
ul=100
else
ul=200
endif
changelim = 1
end 
2 Feb 2009 3:45 (Edited: 26 Jun 2009 2:18) #4276

ii and ul are in the same common block. If you put them in different common blocks, you only have to put the one containing ul in changelim.

If you write fortran in 90 / 95 style, you can declare ii and ul to have a scope that includes the callbacks, so you don't need common.

I found the static nature of the limits, plus the fact that you can't have the two limits the same, a major limitation of %il. By the time you have programmed your own callback, and found it rather easy, you wonder what %il is there for.

E

26 Jun 2009 12:55 #4731

DId the function Paul mentioned ever get implemented.? I would be very keen to be able to update the upper limits dynamically.

1 Jul 2009 12:39 #4734

I should try the approach you have indicated as the following date enquiry I wrote does not work well at all.

I have specified a valid year as being from 1901 to max_year = 2020. I can only change the values with the spinl wheel, as it is impossible to type a digit into the %rd field. The %il applies after each key press and if I insert or remove a digit, it automatically goes out of range. I realy only want the %il to apply after I have completed changing the number. If 0 is not a valid number then %il does not allow the number to be deleted. The other warning that should be in bold with %il is to follow the use of %il with %`il to turn it off for possible further %rd's.

I need to attach a limit test to the ok button and reject the ok if any are out of range.

John

      i = winio@ ('%il&', 1, days_per_month(mm))
      i = winio@ ('%nl%dd%3rd&', 1, dd)
      i = winio@ ('%il&', 1, 12)
      i = winio@ ('%ta%dd%3rd&', 1, mm)
      i = winio@ ('%il&', 1901, max_year)
      i = winio@ ('%ta%dd%5rd&', 1, yyyy)
6 Jul 2009 2:24 #4760

I have now added two new subroutines for the next release. These will change the %il and %fl limits dynamically. They will operate as follows...

winapp
program limits
integer iw,ihwnd,cb,imin,imax,winio@,n
common ihwnd,imin,imax
external cb
imin = 1
imax = 100
iw=winio@('%il&',imin,imax)
iw=winio@('Number: %rd&',n)
iw=winio@('%lc&',ihwnd)
iw=winio@('%ff&')
iw=winio@('%co[check_on_focus_loss]&')
iw=winio@('Min: %^rd&',imin, cb)
iw=winio@('%ff&')
iw=winio@('Max: %^rd',imax, cb)
end

integer function cb()
include <windows.ins>
integer ihwnd,imin,imax
common ihwnd,imin,imax
call set_integer_limits@(ihwnd, imin, imax)
cb=1
end

Notes:

  1. If imax ⇐ imin in the call to set_integer_limits@ then the limits are removed.
  2. set_float_limits@ will do the same for %fl.
7 Jul 2009 12:07 #4766

Paul,

Thanks for the example. [check_on_focus_loss] solved my problem with the year limits, when I used ('%il&', 1900, 2020).

John

Please login to reply.