[erlang-questions] dets:info/2

Tim erlang@REDACTED
Sun Jun 30 17:37:19 CEST 2013


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}]},

…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.

More information about the erlang-questions mailing list