|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Wed Jul 06, 2016 7:23 pm Post subject: Ganged buttons |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Thu Jul 07, 2016 7:50 am Post subject: |
|
|
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 |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Fri Jul 08, 2016 3:02 pm Post subject: |
|
|
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 |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Sat Jul 09, 2016 1:10 pm Post subject: |
|
|
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 |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Sat Jul 09, 2016 1:24 pm Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Sat Jul 09, 2016 4:13 pm Post subject: |
|
|
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 |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Sat Jul 09, 2016 4:15 pm Post subject: |
|
|
I should have realised that from previous posts. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Sat Jul 09, 2016 6:49 pm Post subject: |
|
|
This is great. Thanks to all. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Sat Jul 16, 2016 5:03 am Post subject: |
|
|
Paul wrote:-
Quote: | The * is already available. |
??????? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Sat Jul 16, 2016 6:50 am Post subject: |
|
|
The character '*' in the code '%*`~ga&'. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Wed Aug 24, 2016 5:52 am Post subject: |
|
|
Thanks again for setting that up, Paul. Would it be possible to do something similar with %*ps? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Wed Aug 24, 2016 6:55 am Post subject: |
|
|
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 |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Sun Aug 28, 2016 10:39 am Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Mon Aug 29, 2016 9:19 am Post subject: |
|
|
OK. I have now added a tilda modifier to %ps for the next release. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Apr 21, 2017 10:16 pm Post subject: |
|
|
... 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 |
|
|
|
|
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
|