sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Thu Nov 11, 2010 4:28 pm Post subject: Property sheet syntax limitations |
|
|
Been a while since I had call to use %sh and %ps but it happened today. Thought I had a really elegant solution till I came to code it and then found I had shot myself in the foot ...
Once the property sheet children have been set up using a series of %sh controls, they have to be activated using a %ps control, the syntax for which is:
| Code: |
| i = winio@ ('%Nps', h1, h2, ... , hN) |
where h1 ... hN are the handles of the individual children. Now there's nothing to stop a program using a loop to set up a family of children, the size of which is not known until run-time, but the %ps syntax prevents them from being activated elegantly because the handles have to be enumerated explicitly.
One of the joys of using ClearWin+ is discovering that the syntax is powerful enough to accommodate occasional "I wonder if ...?" imagination, on the basis of which I tried the following:
| Code: |
do j = 1, n
i = winio@ ('%sh', h (j))
end do
i = winio@ ('%*ps', n, (h (j), j = 1, n)) |
but alas, on this occasion my imagination appears to have defeated the compiler, which issues me with error 571 - ',' found where ')' was expected.
Can I suggest that the %ps control could usefully be developed to accommodate the more flexible syntax above? Fortunately, I can work around the limitation in the code I am currently working on, where the number of children, though variable, is always going to be small enough to allow me to select a specific line of Clearwin+ code from a menu of hard-coded alternatives:
| Code: |
if (n .eq. 2) then
i = winio@ ('%*ps', 2, h (1), h (2))
else if (n .eq. 3) then
i = winio@ ('%*ps', 3, h (1), h (2), h (3))
else ...
...
else if (n .eq. nmax) then
i = winio@ ('%*ps', nmax, h (1), h (2), h (3), ... , h (nmax))
end if |
But really, bleurgh ... |
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Fri Nov 12, 2010 10:58 am Post subject: |
|
|
There is a way to do this, see the help file under "Advanced use of format windows".
There is a set of routines that allow you to build a winio@ list before calling winio@. In other words the list is built and then the winio@ call only provides the format via one argument.
subroutine add_winio_integer@(integer_val)
subroutine add_winio_float@(real8_val)
subroutine add_winio_function@(func_name)
These can be used within a do loop to give the flexibility that you require. |
|