Erl中的记录(Erlang问题)

时间:2009-09-06 17:35:54

标签: erlang mnesia erl

有没有办法在erl中直接使用记录?无论我尝试什么,它总是说它无法找到记录。我正在尝试进行mnesia交易,没有我的记录,我不能走得太远。非常感谢任何帮助 - 谢谢!

2 个答案:

答案 0 :(得分:13)

是的,使用help()并在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

这些是shell中的一个聪明的黑客,它们允许您在编译时加载模块中使用的记录定义。使用rr命令从模块加载它。

请记住,这些仅适用于要使用的交互式shell。

答案 1 :(得分:3)

你是什么意思?在外壳中,它就像克里斯蒂安写的那样。如果您在模块中表示,那么您仍然必须先定义记录才能使用它们。有关如何执行此操作的说明,请参阅http://erlang.org/doc/在线的erlang文档。它们只是一个编译时构造,因此它们不存在。

相关问题