<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>This works (and is simple!):<br>
</p>
loop(Orbiter1, Orbiter2, Orbiter3) -><br>
<br>
receive {Orbiter1,{{X1, Y1, Z1}}} -> ok end,<br>
receive {Orbiter2,{{X2, Y2, Z2}}} -> ok end,<br>
receive {Orbiter3,{{X3, Y3, Z3}}} -> ok end,<br>
<br>
io:format("X1: ~p, Y1: ~p, Z1: ~p~n", [X1, Y1, Z1]),<br>
io:format("X2: ~p, Y2: ~p, Z2: ~p~n", [X2, Y2, Z2]),<br>
io:format("X3: ~p, Y3: ~p, Z3: ~p~n", [X3, Y3, Z3]),<br>
<br>
loop(Orbiter1, Orbiter2, Orbiter3).<br>
<br>
<br>
<div class="moz-cite-prefix">On 09/29/2016 11:02 AM, Vlad Dumitrescu
wrote:<br>
</div>
<blockquote
cite="mid:CAA-EFXu4fQPoSEMbd8cOgbYoN8jVZbP9XDGxGYXFz=A_AC9X1Q@mail.gmail.com"
type="cite">
<div dir="ltr">The crash is because the message doesn't look like
I assumed. I didn't pay attention and didn't see that it should
be {{X, Y, Z}} = Coordinates (two levels of braces)
<div><br>
</div>
<div>To get rid of the warning, you can rewrite </div>
<div><br>
</div>
<div><span style="font-size:12.8px">loop(Orbiter1) -></span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> receive</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> {Orbiter1,
Coordinates={{X,Y,Z}}} -> </span><br
style="font-size:12.8px">
<span style="font-size:12.8px">
io:format("Coordinates: ~p~n", [Coordinates]),</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> io:format("X: ~p,
Y: ~p, Z: ~p~n", [X, Y, Z])</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> end,</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"><span style="font-size:12.8px">
loop(Orbiter1).</span><br style="font-size:12.8px">
</span></div>
<div><span style="font-size:12.8px"><span
style="font-size:12.8px"><br>
</span></span></div>
<div><span style="font-size:12.8px"><span
style="font-size:12.8px">For a real server, you probably
want to handle more messages, and ignore those you don't
care about. For example</span></span></div>
<div><span style="font-size:12.8px"><span
style="font-size:12.8px"><br>
</span></span></div>
<div><span style="font-size:12.8px">loop(Orbiter1) -></span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> receive</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> {Orbiter1,
Coordinates={{X,Y,Z}}} -> </span><br
style="font-size:12.8px">
<span style="font-size:12.8px">
io:format("Coordinates: ~p~n", [Coordinates]),</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> io:format("X: ~p,
Y: ~p, Z: ~p~n", [X, Y, Z]),</span></div>
<div>
<div><span style="font-size:12.8px"><span
style="font-size:12.8px"> loop(Orbiter1);</span><br
style="font-size:12.8px">
</span></div>
<div><span style="font-size:12.8px"><span
style="font-size:12.8px"> _ -></span></span></div>
<div> ok % stop if unknown message arrives</div>
<span style="font-size:12.8px"> end.</span><br
style="font-size:12.8px">
</div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div>regards,<br>
</div>
<div>Vlad</div>
<div><br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Sep 29, 2016 at 4:52 PM,
Donald Steven <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:t6sn7gt@aim.com" target="_blank">t6sn7gt@aim.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Alas that produces:</p>
<p><span style="font-size:12.8px">problem.erl:26:
Warning: variable 'Coordinates' exported from
'receive' (line 26)<br>
{"init terminating in
do_boot",{{badmatch,{{-4.99800<wbr>0e+02,6.000000e-01,2.000000e-<wbr>01}}},[{problem,loop,1,[{file,<wbr>"problem.erl"},{line,29}]},{<wbr>init,start_em,1,[]},{init,do_<wbr>boot,3,[]}]}}<span><br>
init terminating in do_boot ()<br>
</span></span><span style="font-size:12.8px"></span></p>
<span> <br>
<div>On 09/29/2016 10:34 AM, Vlad Dumitrescu wrote:<br>
</div>
<blockquote type="cite"><span style="font-size:12.8px">loop(Orbiter1)
-></span><br style="font-size:12.8px">
<span style="font-size:12.8px"> Coordinates =
receive</span><br style="font-size:12.8px">
<span style="font-size:12.8px"> {Orbiter1,
Coordinates} -> </span><span
style="font-size:12.8px">Coordinates</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> end,</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> {X, Y, Z} =
Coordinates,</span><br style="font-size:12.8px">
<span style="font-size:12.8px">
io:format("Coordinates: ~p~n", [Coordinates]),</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> io:format("X: ~p,
Y: ~p, Z: ~p~n", [X, Y, Z])</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> loop(Orbiter1).</span></blockquote>
<br>
</span></div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</body>
</html>