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 

Dynamically updating listbox %ls

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Steve



Joined: 23 Feb 2007
Posts: 73

PostPosted: Fri Feb 18, 2011 1:41 pm    Post subject: Dynamically updating listbox %ls Reply with quote

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
View user's profile Send private message
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Fri Feb 18, 2011 1:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Steve



Joined: 23 Feb 2007
Posts: 73

PostPosted: Fri Feb 18, 2011 4:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
JohnHorspool



Joined: 26 Sep 2005
Posts: 270
Location: Gloucestershire UK

PostPosted: Fri Feb 18, 2011 4:59 pm    Post subject: Reply with quote

set the initial conditions as :-

Code:
      NONE = 0
      IAPPLES = 1
      IGREEK = 0


it then works !
Back to top
View user's profile Send private message Visit poster's website
Steve



Joined: 23 Feb 2007
Posts: 73

PostPosted: Fri Feb 18, 2011 5:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Fri Feb 18, 2011 5:55 pm    Post subject: Reply with quote

Embarassed 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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ 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