Im trying to simply get this Erlang program to print out a value periodically and I'm using this module to do so:
-module(hot).
-export([start/0,handle_info/2, add/1]).
start() ->
Num = 0,
timer:send_interval(1000, interval),
{ok, Num}.
handle_info(interval, Num) ->
erlang:display(0),
{noreply, Num}.
add(X) ->
X+2.
I'm referencing one of the answers from this post
I also tried using a modification from the top answer as follows:
init([]) ->
Timer = erlang:send_after(1, self(), check),
{ok, Timer}.
handle_info(check, OldTimer) ->
erlang:cancel_timer(OldTimer),
erlang:display(0),
Timer = erlang:send_after(1000, self(), check),
{noreply, Timer}.
Nothing prints out in either case. It just tells me something like {ok,<0.43.0>}. It seems that handle_info is never called at all.