|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Steve
Joined: 23 Feb 2007 Posts: 73
|
Posted: Fri Feb 18, 2011 1:41 pm Post subject: Dynamically updating listbox %ls |
|
|
I would be grateful if anyone could rectify the following code to enable the dynamic update of the listbox. As you can see, I have attempted to use WINDOWS_UPDATE@ on the screen variables but this makes no difference.
PROGRAM TEST
WINAPP
C
C Choosing IAPPLES or IGREEK will only update the 1st
C array element in CITEMS. Why is this ?
C
IMPLICIT REAL*8 (A-H, O-Z)
IMPLICIT INTEGER*2 (J)
C
INCLUDE <WINDOWS.INS>, NOLIST
C
EXTERNAL RB_FUNC
INTEGER RB_FUNC
C
CHARACTER CITEMS(10)*20
C
COMMON / TEST_LS / NONE, IAPPLES, IGREEK,
* ITEM, NITEMS, CITEMS, IGREY
C
NONE = 1
IAPPLES = 0
IGREEK = 0
C
I = RB_FUNC()
C
I = WINIO@('%3`ga&', NONE, IAPPLES, IGREEK)
I = WINIO@('Fill list box with :&')
I = WINIO@('%ff%2ta%^rb[none]&', NONE, RB_FUNC)
I = WINIO@('%ff%2ta%^rb[Apples]&', IAPPLES, RB_FUNC)
I = WINIO@('%ff%2ta%^rb[Greek]&', IGREEK, RB_FUNC)
I = WINIO@('%ff %ffList box :&')
I = WINIO@('%ff%2ta%`~ls', CITEMS, NITEMS, ITEM, IGREY)
C
END
INTEGER FUNCTION RB_FUNC()
C --------------------------
C
IMPLICIT REAL*8 (A-H, O-Z)
IMPLICIT INTEGER*2 (J)
C
INCLUDE <WINDOWS.INS>, NOLIST
C
CHARACTER CITEMS(10)*20
C
COMMON / TEST_LS / NONE, IAPPLES, IGREEK,
* ITEM, NITEMS, CITEMS, IGREY
C
ITEM = 1
CITEMS = ' '
IGREY = 1
C
IF (NONE.GT.0) THEN
NITEMS = 1
CITEMS(1) = 'none'
IGREY = 0
ELSEIF (IAPPLES.GT.0) THEN
NITEMS = 4
CITEMS(1) = 'Braeburn'
CITEMS(2) = 'Bramley'
CITEMS(3) = 'Cox Pippin'
CITEMS(4) = 'Granny Smith'
ELSEIF (IGREEK.GT.0) THEN
NITEMS = 3
CITEMS(1) = 'Alpha'
CITEMS(2) = 'Beta'
CITEMS(3) = 'Gamma'
ENDIF
C
C Following WINDOW_UPDATEs make no difference...
C
C CALL WINDOW_UPDATE@(NITEMS)
C CALL WINDOW_UPDATE@(ITEM)
C DO N = 1, 10
C CALL WINDOW_UPDATE@(CITEMS(N))
C ENDDO
C
RB_FUNC = 1
C
END |
|
Back to top |
|
|
sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Fri Feb 18, 2011 1:49 pm Post subject: |
|
|
Isn't the problem that you have this line:
CHARACTER CITEMS(10)*20
in the main program and the callback, but not in common? |
|
Back to top |
|
|
Steve
Joined: 23 Feb 2007 Posts: 73
|
Posted: Fri Feb 18, 2011 4:26 pm Post subject: |
|
|
Thanks for coming to me sparge.
Sorry, but CITEMS is indeed in COMMON which is why when you click on the Apples or Greek radio buttons at least the first element is updated. All the remaining elements are not available in the list. |
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Fri Feb 18, 2011 4:59 pm Post subject: |
|
|
set the initial conditions as :-
Code: | NONE = 0
IAPPLES = 1
IGREEK = 0 |
it then works ! |
|
Back to top |
|
|
Steve
Joined: 23 Feb 2007 Posts: 73
|
Posted: Fri Feb 18, 2011 5:44 pm Post subject: |
|
|
Thanks John, but I need to start with the 'none' case.
But I believe I have just cracked the problem : always give NITEMS the maximum nos elements. Silverforst will then permit this value as the maximum to consider. The perceived list is only the actual number of items provided.
So, if Apples is set first as John suggested this informs Clearwin+ when setting the %ls up there is a max of 4 elements. And so, Greek will be acceptable. Now try setting Greek up fist, only the first 3 elements of Apples is permtted.
Naturally, I always present NITEMS to %ls as the known number of array elements. So, to overcome dynamically varying arrays I need to set NITEMS to be the maximum of possible values !
Thanks for the feedback. |
|
Back to top |
|
|
sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Fri Feb 18, 2011 5:55 pm Post subject: |
|
|
my bad for not spotting CITEMS in COMMON. Sorry! I actually did try and build and run your code but got a load of error messages because of my compiler options.
You are right, the parameter NITEMS can not be changed dynamically. Whatever value is used first will persist till the window is closed, even if the value of the variable itself is changed. The good news is that ClearWin+ is smart enough to suppress blank items at the end of the list - which gives the impression that NITEMS is varying dynamically. |
|
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
|