Silverfrost Forums

Welcome to our forums

Clearwin text boxes

4 Sep 2006 1:12 #981

Hi,

I would like to be able to use more than one text box or label(I'm not sure what they are called), on a clearwin gui, and be able to update them independantly. However when I update the boxes, all updates are directed at only one box. The following code shows the problem. the second textbox doesn't get updated.

Many thanks

Albert

WINAPP PROGRAM testTextBoxes IMPLICIT NONE INCLUDE <windows.ins> EXTERNAL updatetext1 EXTERNAL updatetext2 INTEGER ans CHARACTER*50 str1,str2 COMMON str1, str2 str1=' ' str2=' ' ans=winio@('%ca[Number Factoriser]&') ans=winio@('%ta%`^bt[Updatetext1]&',updatetext1) ans=winio@('%ta%^bt[Updatetext2]&',updatetext2) ans=winio@('%2nl%ob%42st%cb&',str1) ans=winio@('%2nl%ob%42st%cb',str2) END

INTEGER FUNCTION updatetext1() CHARACTER*50 str1 COMMON str1 str1='hello' CALL window_update@(str1) updatetext1=1 END

INTEGER FUNCTION updatetext2() CHARACTER*50 str2 COMMON str2 str2='goodbye' CALL window_update@(str2) updatetext2=1 END

4 Sep 2006 4:44 #983

Use the same common declaration in all routines.

CHARACTER*50 str1,str2 COMMON str1, str2

Better still, define str1 and str2 in a module and use the module in all routines. One of the benefits of modules is it takes away the problems with common declaration compatibility. There are lots of others, but the ability to define (once) and use variables globally, wherever they are USEd removes a lot of simple coding errors.

WINAPP module string_definition CHARACTER*50 str1,str2 end module string_definition

PROGRAM testTextBoxes use string_definition IMPLICIT NONE INCLUDE <windows.ins> EXTERNAL updatetext1 EXTERNAL updatetext2 INTEGER ans

str1=' ' str2=' ' ans=winio@('%ca[Number Factoriser]&') ans=winio@('%ta%`^bt[Updatetext1]&',updatetext1) ans=winio@('%ta%^bt[Updatetext2]&',updatetext2) ans=winio@('%2nl%ob%42st%cb&',str1) ans=winio@('%2nl%ob%42st%cb',str2) END

INTEGER FUNCTION updatetext1() use string_definition

str1='hello' CALL window_update@(str1) updatetext1=1 END

INTEGER FUNCTION updatetext2() use string_definition

str2='goodbye' CALL window_update@(str2) updatetext2=1 END

5 Sep 2006 12:18 #984

Thankyou very much! thats just what I wanted. I was using the 'common' statement as it's used in the clearwin+ examples a lot.

5 Sep 2006 11:59 #986

Albert,

Sorry to have to disagree with you, but your problem stemmed from your incorrect usage of the common statement, as John Campbell pointed out. The examples that I've seen have always used the common statement correctly. I only use common statements in my Clearwin+ code to pass data.

regards John

7 Sep 2006 6:56 #999

quote: acp693 Thankyou very much! thats just what I wanted. I was using the 'common' statement as it's used in the clearwin+ examples a lot. end quote

John Horspool, yes I realize I was doing something wrong. I'm puzzled as to what you disagree with, as I simply stated that I was using the common statement(instead of the module/use approach as suggested by John Cambell) as it's used in the examples a lot. I wasn't aware that one could declare the variables in a module and then make them available with the use statement.

Thanks

Albert

9 Sep 2006 3:32 #1005

Yes Bruce, I think you are right. Anyway, I'm happy that my problem is solved. Thanks to all that helped.

Regards

Albert

Please login to reply.