replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - How to change %il upper limit while program running?
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 

How to change %il upper limit while program running?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
acp693



Joined: 04 Sep 2006
Posts: 56

PostPosted: Mon Feb 02, 2009 12:14 am    Post subject: How to change %il upper limit while program running? Reply with quote

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]&', 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@ ('%il&', 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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Feb 02, 2009 3:29 pm    Post subject: Reply with quote

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



Joined: 04 Sep 2006
Posts: 56

PostPosted: Mon Feb 02, 2009 3:33 pm    Post subject: Reply with quote

Thanks Paul, I will look into a workaround.

Regards

Albert
Back to top
View user's profile Send private message
acp693



Joined: 04 Sep 2006
Posts: 56

PostPosted: Mon Feb 02, 2009 4:07 pm    Post subject: Reply with quote

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.


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



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

PostPosted: Mon Feb 02, 2009 4:45 pm    Post subject: Reply with quote

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


Last edited by LitusSaxonicum on Fri Jun 26, 2009 3:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 299

PostPosted: Fri Jun 26, 2009 1:55 pm    Post subject: %il dynamic limits Reply with quote

DId the function Paul mentioned ever get implemented.? I would be very keen to be able to update the upper limits dynamically.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Wed Jul 01, 2009 1:39 am    Post subject: Reply with quote

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

Code:

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


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

PostPosted: Mon Jul 06, 2009 3:24 pm    Post subject: Reply with quote

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...

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



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Tue Jul 07, 2009 1:07 am    Post subject: Reply with quote

Paul,

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

John
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 -> Support 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