|
|
| Author |
Message |
< Erlang ~ problem with spawn |
| klm |
Posted: Sun May 24, 2009 9:01 pm |
|
|
|
User
Joined: 11 May 2009
Posts: 18
|
hey !
I'm trying to launch a function in another files with the function spawn
I don't know why it did'nt works
maybe because it's not the same module
Gui_pid = spawn(?Gui, gui:start, [Self,Name,Position]),
How can I use the function spawn ?
thanks |
|
|
| Back to top |
|
| ates |
Posted: Sun May 24, 2009 11:23 pm |
|
|
|
Joined: 23 May 2009
Posts: 3
|
May be follows will help:
$ cat x.erl
-module(x).
-export([start/1]).
start(Msg) ->
io:format("Hello from x module: ~p~n", [Msg]).
$ cat y.erl
-module(y).
-export([start/0]).
start() ->
spawn(x, start, ["Hello"]).
$ erl
Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]
Eshell V5.7.1 (abort with ^G)
1> y:start().
Hello from x module: "Hello"
<0.35.0> |
|
|
| Back to top |
|
| klm |
Posted: Mon May 25, 2009 10:45 am |
|
|
|
User
Joined: 11 May 2009
Posts: 18
|
yes it works !
it was easy in fact.
I begin in this language and I've some problems sometimes which are not really big problems finally. |
|
|
| Back to top |
|
| Mazen |
Posted: Thu May 28, 2009 6:41 pm |
|
|
|
User
Joined: 20 Jul 2006
Posts: 164
Location: London
|
klm; the real error is that you are using module:function it should be module,function..
so instead of:
Gui_pid = spawn(?Gui, gui:start, [Self,Name,Position]),
use:
Gui_pid = spawn(?Gui, gui, start, [Self,Name,Position]),
see this link for more info:
http://www.erlang.org/doc/man/proc_lib.html |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
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 You cannot attach files in this forum You cannot download files in this forum
|
|
|