Mickael Remond mikl@REDACTED
Thu Jun 24 17:22:47 CEST 1999


I get a compile time error message when trying to use record_info/2 outside of the 'mnesia:create_table' context.

The error message is :
illegal record info

What I am trying to do is get the list of fields of an object :
(The aim of the function is to replace a fields value by its name, without specifically knowing what kind of record I am manipulating)

replace(Attr,Value, Obj) ->
    %% Get record_name from Object
    Record_name = element(1,Obj),
    %% Get list of fields
    List = record_info(fields, Record_name),
    %% Get attribute position
    %% +1 because of the table name at first position
    Pos = pos(Attr,List) + 1,
    case Pos of
	0 ->
	    {error, attribute_does_not_exist_in_record};
	N ->
	    Result = setelement(Pos, Obj, Value),

Can you figure out what I am doing wrong or what I am misunderstanding ? 

Thanks in advance for your help.

Mickael Remond
ICQ : 2265396

More information about the erlang-questions mailing list