Silverfrost Forums

Welcome to our forums

Dynamically updating listbox %ls

18 Feb 2011 12:41 #7789

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 REAL8 (A-H, O-Z) IMPLICIT INTEGER2 (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@('%3ga&amp;', NONE, IAPPLES, IGREEK) I = WINIO@('Fill list box with :&amp;') I = WINIO@('%ff%2ta%^rb[none]&amp;', NONE, RB_FUNC) I = WINIO@('%ff%2ta%^rb[Apples]&amp;', IAPPLES, RB_FUNC) I = WINIO@('%ff%2ta%^rb[Greek]&amp;', IGREEK, RB_FUNC) I = WINIO@('%ff %ffList box :&amp;') I = WINIO@('%ff%2ta%~ls', CITEMS, NITEMS, ITEM, IGREY) C END

  INTEGER FUNCTION RB_FUNC()

C -------------------------- C IMPLICIT REAL8 (A-H, O-Z) IMPLICIT INTEGER2 (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

18 Feb 2011 12:49 #7790

Isn't the problem that you have this line:

CHARACTER CITEMS(10)*20

in the main program and the callback, but not in common?

18 Feb 2011 3:26 #7791

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.

18 Feb 2011 3:59 #7794

set the initial conditions as :-

      NONE = 0
      IAPPLES = 1
      IGREEK = 0 

it then works !

18 Feb 2011 4:44 #7795

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.

18 Feb 2011 4:55 #7797

😮ops: 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.

Please login to reply.