Use of It in concurrent processes

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Use of It in concurrent processes

Post by kolia » Tue Oct 20, 2015 1:45 pm

Hello,

I have a routine that reads a socket every x seconds. Each read statement put the result in the It variable. Beside that there are user interactions that may lead to using the read socket command as well. In that scenario I have a "chance" to get a value in the It variable that is not the one that is expected. Is there a way to have the read command returning the result in another variable?
Thank you
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Use of It in concurrent processes

Post by Klaus » Tue Oct 20, 2015 4:19 pm

Hi kolia,
kolia wrote:Is there a way to have the read command returning the result in another variable?
no!

But you should put IT into another variable IMMEDIATELY after getting IT!
That is the only way to prevent this kind of inconvenience.


Best

Klaus

kolia
Posts: 82
Joined: Thu May 28, 2015 3:53 pm

Re: Use of It in concurrent processes

Post by kolia » Tue Oct 20, 2015 4:41 pm

This indeed what I do. But I found a trick: I use the peerAddress of host:port command that returns "not an open socket" in case the device is free.
Nicolas
LC 7.1 on Windows 8.1 and on MAC OS 10.10.5 Xcode 6.4 - 7.1

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Use of It in concurrent processes

Post by dunbarx » Tue Oct 20, 2015 5:37 pm

Hi,

Glad you found a workaround.

Now do what Klaus said. Always, always put the value of "it", however obtained (answer dialog, read..., convert, whatever) into another variable right away. You will be glad you did.

Craig Newman

Post Reply