[erlang-questions] dets:info/2

Joseph Wayne Norton norton@REDACTED
Sun Jun 30 17:51:14 CEST 2013


Tim -

MyInfo is an integer.  You need to convert it to a string before using the "++" operator.  A string is simply a list of integers in Erlang.



$ erl
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.2  (abort with ^G)
1> dets:open_file(ingredients, [{file,"ingredients.dets"},{type,set}]).
{ok,ingredients}
2> 
2> MyInfo = dets:info(ingredients,no_objects).
0
3> integer_to_list(MyInfo).
"0"



On 2013/06/30, at 10:37, Tim <erlang@REDACTED> wrote:

> Joseph,
> 
> Yes, I have entered the commands into the running shell, and all I get back is the simple value "3" on a line, by itself, with nothing else - no error.  That behaviour is what was expected.
> 
> When I simply try to display the variable that contains that value using {html, MyInfo}, it prints nothing - but does not generate an error either.
> 
> If, however, I try to mix it in with some other HTML in this fashion:
> 
> {html,"<h1>" ++ MyInfo ++ "</h1>\n").
> 
> then it crashes:
> 
> ERROR erlang code threw an uncaught exception:
> File: /Users/tim/website/ingredients.yaws:51
> Class: error
> Exception: badarg
> Req: {http_request,'GET',{abs_path,"/ingredients.yaws"},{1,1}}
> Stack: [{m41,out,1,[{file,"/Users/tim/.yaws/yaws/default/m41.erl"},{line,19}]},
>        {yaws_server,deliver_dyn_part,8,
>                     [{file,"yaws_server.erl"},{line,2750}]},
>        {yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1175}]},
>        {yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1016}]},
>        {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]
> 
> …and, unfortunately, I can't make any sense of that error message.
> 
> I don't understand this bizarre behaviour.
> 
> 
> 
> On 01/07/2013, at 12:39 AM, Joseph Wayne Norton <norton@REDACTED> wrote:
> 
>> Have you tried these commands using the erlang shell?
>> 
>> $ erl
>> Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]
>> 
>> Eshell V5.10.2  (abort with ^G)
>> 1> dets:open_file(ingredients, [{file,"ingredients.dets"},{type,set}]).
>> {ok,ingredients}
>> 2> MyInfo = dets:info(ingredients,no_objects).
>> 0
>> 3> 
>> 
>> 
>>> Can anyone provide some example code of dets:info/2 in action that actually works?
>>> 
>>> I'm trying to get info on a dets table through a .yaws script and just can't get it to work.
>>> 
>>> <erl>
>>> out(Arg) ->
>>> 	dets:open_file(ingredients, [{file,"ingredients.dets"},{type,set}]),
>>> 	MyInfo = dets:info(ingredients,no_objects),
>>> 	{html, MyInfo}.
>>> </erl>
>>> 
>>> The error occurs on the {html, MyInfo} line - it appears to be unable to display the value.
>>> 
>>> My reading of the docs suggests that the return value of sets:info/2 is a simple value, but I suspect that it is not and have not yet worked out a way of visualising what sort of structure is being returned by the function.
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list