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 

Ganged buttons
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Wed Jul 06, 2016 7:23 pm    Post subject: Ganged buttons Reply with quote

The following code represents a trivial example of ganging some radio buttons.

Code:
WINAPP
PROGRAM p
  USE clrwin, ONLY: winio@
  INTEGER, PARAMETER :: n=3
  INTEGER, DIMENSION(n) :: irbs
  CHARACTER(LEN=1), DIMENSION(n) :: crbs= (/'A','B','C'/)
  INTEGER :: iw

  irbs(1)=1
  irbs(2:)=0
  iw=winio@('%3`ga&',irbs(1),irbs(2),irbs(3))
  DO i=1,n
     iw=winio@('%nl%rb@&',crbs(i),irbs(i))
  END DO
  iw=winio@('%ff')

END PROGRAM p


Although everything works, the format of line 11 is proving to be very restrictive. If line 11 could be changed so that the argument to %ga is an array I think it would become much more flexible. For example, it would be very helpful if line 11 could be written as:

Code:
iw=winio@('%3`ga&',irbs(1:n))


In this format it would be easier to convert the code above to a subroutine that would gang a set of n buttons where n is passed as an argument. (The "3" after the % sign could easily be coded to the correct number, of course.) Right now my subroutine has to look something like the following:


Code:
SELECT CASE (n)
   CASE (2)
     iw=winio@('%2`ga&',irbs(1),irbs(2))
   CASE (3)
     iw=winio@('%3`ga&',irbs(1),irbs(2),irbs(3))
   CASE (4)
     iw=winio@('%4`ga&',irbs(1),irbs(2),irbs(3),irbs(4))
     ...


Would it be possible to get %ga to accept an array argument instead of individual scalars? Or am I missing a more obvious way to do this?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Jul 07, 2016 7:50 am    Post subject: Reply with quote

OK. This has been added via a tilda modifier so that you will be able to write...

Code:
WINAPP
PROGRAM p
  INTEGER, PARAMETER :: n=3
  INTEGER, DIMENSION(n) :: irbs
  CHARACTER(LEN=1), DIMENSION(n) :: crbs = (/'A','B','C'/)
  INTEGER :: iw,winio@
  irbs = 0
  irbs(1)=1
  iw=winio@('%3`~ga&',irbs)
  DO i=1,n
     iw=winio@('%nl%rb@&',crbs(i),irbs(i))
  END DO
  iw=winio@('%ff')
END PROGRAM p
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Fri Jul 08, 2016 3:02 pm    Post subject: Reply with quote

That is a very helpful addition, and one might say an 'obvious' one to implement.

The job would be complete if the N in %Nga was also allowed to be defined as a parameter.

I often find it useful to have all the state codes in an integer array, for example grey codes.
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Sat Jul 09, 2016 1:10 pm    Post subject: Reply with quote

Of course you can already do this in a slightly devious way

Code:
WINAPP
PROGRAM p
  INTEGER, PARAMETER :: n=3
  INTEGER, DIMENSION(n) :: irbs
  CHARACTER(LEN=1), DIMENSION(n) :: crbs = (/'A','B','C'/)
  INTEGER :: iw,winio@
  irbs = 0
  irbs(1)=1
  do I=2,n
    iw=winio@('%2`ga&',irbs(I-1),irbs(I))
  enddo
  DO i=1,n
     iw=winio@('%nl%rb@&',crbs(i),irbs(i))
  END DO
  iw=winio@('%ff')
END PROGRAM p

As it says in the documentation
"However, it is unusual for a variable to appear in more than one %ga format for a given window. If it does then there must only be one variable that is common and the effect is to merge the two gang sets. If the grave accent is used on one of the gangs then it must be used on both."
Ian
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



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

PostPosted: Sat Jul 09, 2016 1:24 pm    Post subject: Reply with quote

Good idea there, Ian, and I have to say that to conform to a Windows style guide, all radio buttons should be present at all times, with the inactive ones greyed out. That simplifies dialog box layout.

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


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

PostPosted: Sat Jul 09, 2016 4:13 pm    Post subject: Reply with quote

This is the code. The * is already available. The ~ will be in the next release.
As a general principle these sizes (after % and before the two letter format code) can be replaced by * provided an extra argument (or two for *.*) is supplied at the corresponding point.

Code:
WINAPP
PROGRAM p
  INTEGER, PARAMETER :: n=3
  INTEGER, DIMENSION(n) :: irbs
  CHARACTER(LEN=1), DIMENSION(n) :: crbs = (/'A','B','C'/)
  INTEGER :: iw,winio@
  irbs = 0
  irbs(1)=1
  iw=winio@('%*`~ga&',n,irbs)
  DO i=1,n
     iw=winio@('%nl%rb@&',crbs(i),irbs(i))
  END DO
  iw=winio@('%ff')
END PROGRAM p
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Sat Jul 09, 2016 4:15 pm    Post subject: Reply with quote

I should have realised that from previous posts.
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Sat Jul 09, 2016 6:49 pm    Post subject: Reply with quote

This is great. Thanks to all.
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Jul 16, 2016 5:03 am    Post subject: Reply with quote

Paul wrote:-
Quote:
The * is already available.

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


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

PostPosted: Sat Jul 16, 2016 6:50 am    Post subject: Reply with quote

The character '*' in the code '%*`~ga&'.
Back to top
View user's profile Send private message AIM Address
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Wed Aug 24, 2016 5:52 am    Post subject: Reply with quote

Thanks again for setting that up, Paul. Would it be possible to do something similar with %*ps?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Aug 24, 2016 6:55 am    Post subject: Reply with quote

It should work already. This is a general feature that should work whenever one or two integers come before the two letter format code.
Back to top
View user's profile Send private message AIM Address
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Sun Aug 28, 2016 10:39 am    Post subject: Reply with quote

Sorry - I should have been clearer. I meant would it be possible to get %*ps to accept an array as its argument?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Aug 29, 2016 9:19 am    Post subject: Reply with quote

OK. I have now added a tilda modifier to %ps for the next release.
Back to top
View user's profile Send private message AIM Address
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Fri Apr 21, 2017 10:16 pm    Post subject: Reply with quote

... I am finding this enhancement so useful, I would like to ask Paul to do even more work! Could you do something similar for %Ntl, Paul; i.e., allow the list of tab positions to be an array? The * for N seems to work already.
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  Next
Page 1 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