Search code examples
erlangmnesiaerl

Records in Erl (Erlang question)


Is there a way to use records directly in erl? No matter what I try, it always says it canno find the record. I am trying to do mnesia transactions and I cannot go too far without my records. Any help is greatly appreciated - thank you!


Solution

  • Yes, use help() and find these commands in the shell.

    rd(R,D)    -- define a record
    rf()       -- remove all record information
    rf(R)      -- remove record information about R
    rl()       -- display all record information
    rl(R)      -- display record information about R
    rp(Term)   -- display Term using the shell's record information
    rr(File)   -- read record information from File (wildcards allowed)
    rr(F,R)    -- read selected record information from file(s)
    rr(F,R,O)  -- read selected record information with options
    

    These are a clever hack in the shell, they allow you to load record definitions used in modules when they were compiled. Use the rr command to load it from your module.

    Remember that these are only available for the interactive shell to use.