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
-
p4tr1ck
- Posts: 36
- Joined: Mon Jun 14, 2010 4:58 pm
Post
by p4tr1ck » Sun Oct 24, 2010 5:04 pm
Well, I'm making an IRC client, and have messages going back and forth so thats good.
But my problem is that to constantly check for messages received from the server, I'm using something like this:
Code: Select all
repeat forever with messages
-check for messages-
wait 3 milliseconds with messages
end repead
Is there a better way to be constantly doing something? This crashes often, and I usually have to abort it before I can even add anything to the stack.
Thanks.
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sun Oct 24, 2010 5:09 pm
p4tr1ck ,
Your script should look similar to
Code: Select all
on readFromSocket theIP,theMsg
if theMsg is "makes sense" then
read from socket theIP with message "readFromSocket"
else
-- stop
end if
end readFromSocket
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
p4tr1ck
- Posts: 36
- Joined: Mon Jun 14, 2010 4:58 pm
Post
by p4tr1ck » Sun Oct 24, 2010 5:28 pm
Thanks for the fast reply!
I didn't even think to use a message. Thanks

-
p4tr1ck
- Posts: 36
- Joined: Mon Jun 14, 2010 4:58 pm
Post
by p4tr1ck » Sun Oct 24, 2010 5:44 pm
Actually, does this constantly read from the socket?
It seems to be a just a function to me. I already can read from the socket, but I need to figure out how to do that constantly without an infinite loop.
Thanks,
Patrick
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sun Oct 24, 2010 6:03 pm
Hi Patrick,
In this example, the handler will continue to call itself as long as theMsg is "makes sense". Not a very realistic example, but it makes clear how it works.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
p4tr1ck
- Posts: 36
- Joined: Mon Jun 14, 2010 4:58 pm
Post
by p4tr1ck » Sun Oct 24, 2010 6:29 pm
After testing, it seemed that the function did not call itself, after calling that function directly, or after reading from a socket.
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sun Oct 24, 2010 6:33 pm
p4tr1ck ,
Probably you do something wrong

Keep in mind that I made an example. A complete set of scripts takes much more than just that. Are you sure you have set up all scripts of both the server and the client stack correctly?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
p4tr1ck
- Posts: 36
- Joined: Mon Jun 14, 2010 4:58 pm
Post
by p4tr1ck » Sun Oct 24, 2010 6:35 pm
Well, using your example I made another test stack that simply put something into a text field after your function had been called. I attempted to start it with a button that both read from a socket, and called the function directly. However, it had no results.

-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sun Oct 24, 2010 6:44 pm
p4tr1ck,
Look around in this forum for more examples. Spend a few hours figuring out how to do it. Download examples from RevOnline and elsewhere. Once you have a complete set of scripts for both the server and the client and if it still doesn't work, then you might want to post your scripts here and we can tell you what is wrong. Keep it as simple as possible in the beginning.
Good luck,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode