forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

winio inside a do loop is different to separate calls to wi

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
wolf



Joined: 02 Jul 2012
Posts: 11

PostPosted: Sun Feb 28, 2016 3:39 pm    Post subject: winio inside a do loop is different to separate calls to wi Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Feb 29, 2016 8:53 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Mon Feb 29, 2016 11:19 am    Post subject: Reply with quote

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
View user's profile Send private message
wolf



Joined: 02 Jul 2012
Posts: 11

PostPosted: Mon Feb 29, 2016 6:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group