View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri May 21, 2021 2:30 am Post subject: Multiple occurrences of %rs |
|
|
I notice that if you use more than %rs in a window then one apparently has to have a separate declaration for each occurrence. For example, the following code prints two Bs rather than A and B.
Code: | Winapp
Program p
Use clrwin, Only: winio$
Character :: c
Integer :: iw
c = 'A'
iw = winio$('%`rs&', c)
c = 'B'
iw = winio$('%`rs&', c)
iw = winio$(' ')
End Program p
|
Am I correct in assuming that I must store A and B separately?
Last edited by simon on Fri May 21, 2021 9:38 pm; edited 1 time in total |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri May 21, 2021 8:19 am Post subject: |
|
|
simon
%`rs reads from the given character variable so you do need two.
An alternative is to use %ws or simply put the string in the first argument of winio@...
iw = winio@("Hello World") |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Thu May 27, 2021 7:50 pm Post subject: |
|
|
Thanks Paul, So would it be right to suggest using
1) %`rs if there is some possibility I may want to update the string output if the corresponding variable changes value (with the understanding I would have to call window_update@), but
2) %ws if I want to output the current value and do not care about happens to the variable afterwards? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Thu May 27, 2021 8:54 pm Post subject: |
|
|
Yes that would be right. |
|
Back to top |
|
|
|