[erlang-questions] how to use timer:apply_interval/4

Richard Andrews bflatmaj7th@REDACTED
Sun Jul 19 13:08:03 CEST 2009


An escript has no module.

do_task would need to be exported and it would need to be exported
from a module. As a result there is no way to call it.
Similarly the error comes from the fact that there is no module and as
a result ?MODULE expands to (presumably) some internal implementation
value inserted by escript.

HTH
--
  Rich


On Sun, Jul 19, 2009 at 2:01 PM, Oscar<ro4tub@REDACTED> wrote:
>  1 #!/usr/bin/env escript
>  2
>  3 do_task(A) ->
>  4     io:format("~w: now=~w~n", [A, now()]).
>  5
>  6 main(_) ->
>  7     io:format("starting \n"),
>  8     {ok, _} = timer:apply_interval(80, ?MODULE, do_task,["info"]),
>  9     timer:sleep(100),
>  10     io:format("ending \n").
>
>
>
> hkf@REDACTED:~/work/erlang/flower$ ./timer_main.erl
> ./timer_main.erl:3: Warning: function do_task/1 is unused
> starting
>
> =ERROR REPORT==== 19-Jul-2009::11:57:29 ===
> Error in process <0.33.0> with exit value:
> {undef,[{'escript__timer_main.erl__1247__975849__641609',do_task,["info"]}]}
>
> ending
>
>
>
>
> I have two questions:
> 1. how to explain the error log?
> 2. how to get rid of the warning ''function do_task/1 is unused'?
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>


More information about the erlang-questions mailing list