erl startup

Wes James comptekki@REDACTED
Wed May 19 04:59:04 CEST 2010


This is odd:

If I run:

start() ->
	Id_Table=ets:new(start_id_table, []),
	{ok, TRef}=timer:apply_interval(1000*60*5, prt, getc, []), % 1000
milliseconds * 60 * 5 = 5 minutes
	ets:insert(Id_Table, {id, TRef}),
	io:format("Id_Table: ~w~n", [Id_Table]),
	io:format("Id_Table lookup: ~w~n", [ets:lookup(Id_Table, id)]),
	"id_table: " ++ Id_Table.

with the -run my_mod the last io:formats print

Id_Table: 28693
Id_Table: 28693
Id_Table lookup: [{id,{interval,#Ref<0.0.0.1000>}}]

but the "id_table: " ++ Id_Table does not show up in the output.

If I then run

ets:lookup(28693, id).

I get:

** exception error: bad argument
     in function  ets:lookup/2
        called as ets:lookup(28693,id)

If I run erl then type in  my_mod:start()  I get :

Id_Table: 57386
Id_Table: 57386
Id_Table lookup: [{id,{interval,#Ref<0.0.0.1165>}}]
[105,100,95,116,97,98,108,101,58,32|57386]

and the timer works now and the last line is output.

Any explanation here?  Does a timer not continue if it is run from
-run command?  It seems like it stops working if run in -run mode.

thx,

-wes


More information about the erlang-questions mailing list