Silverfrost Forums

Welcome to our forums

Multiple occurrences of %rs

21 May 2021 1:30 (Edited: 21 May 2021 8:38) #27823

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.

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?

21 May 2021 7:19 #27824

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')

27 May 2021 6:50 #27869

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?
27 May 2021 7:54 #27870

Yes that would be right.

Please login to reply.