View previous topic :: View next topic |
Author |
Message |
wolf
Joined: 02 Jul 2012 Posts: 11
|
Posted: Sun Feb 28, 2016 3:39 pm Post subject: winio inside a do loop is different to separate calls to wi |
|
|
Hello,
I observe an unexpected result from a call to winio@ inside a do loop.
Here the loop:
do nr = 1,2
ians = winio@ ('%2nl %`2rd %18rs &', nr, 'ABC')
enddo
The result shows two lines, each beginning with "3" instead of "1" and "2"
Here the two lines which produce the desired result:
nr=1; ians = winio@ ('%2nl %`2rd %18rs &', nr, 'ABC')
nr=2; ians = winio@ ('%2nl %`2rd %18rs &', nr, 'ABC')
Why that ?
Thanks in advance
Wolf |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Mon Feb 29, 2016 8:53 am Post subject: |
|
|
winio@ passes the address of nr and not its value. So you should get the current value of nr whatever it is. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Feb 29, 2016 11:19 am Post subject: |
|
|
I couldn't get 1 & 2 from the non-DO loop code, I got 2 twice. This accords with Paul's reply.
I suggest using different array elements for the variable, so instead of nr, integer_variable(nr). |
|
Back to top |
|
|
wolf
Joined: 02 Jul 2012 Posts: 11
|
Posted: Mon Feb 29, 2016 6:33 pm Post subject: |
|
|
Thanks gentlemen,
I like the suggestion to pass an array element to winio@ instead of a single variable. I works fine and code looks much nicer than 12 individual winio@ lines. |
|
Back to top |
|
|
|