<br><br><div class="gmail_quote">On Wed, Jan 7, 2009 at 2:25 PM, Ulf Wiger (TN/EAB) <span dir="ltr"><<a href="mailto:ulf.wiger@ericsson.com">ulf.wiger@ericsson.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Torben Hoffmann skrev:<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
 You should have a look at the preprocessor function record_info/2 which could give you a list of the field names like this:<br>
<br>
FieldNames = record_info(fields,ewayRequest),<br>
<br>
The problem is that the record name has to be known at compile time so you need a function along these lines:<br>
<br>
record_fields(#evayRequest{}) -><br>
       record_info(fields,ewayRequest);<br>
record_fields(#other_record{}) -><br>
       record_info(fields, other_record).<br>
<br>
The downside is that you need to add a clause every time you define a new record.<br>
The record_fields could be auto-generated using a script by keeping all record definitions in a .hrl file and generate a module with the record_fields function. Any scripting language will suffice here - I have used both sed and Erlang for the job in the past.<br>

</blockquote>
<br></div>
You can also use the exprecs library which does exactly this,<br>
and then some, via a parse transform.<br>
<br>
<a href="http://forum.trapexit.org/viewtopic.php?p=21790#21790" target="_blank">http://forum.trapexit.org/viewtopic.php?p=21790#21790</a><br>
<br>
BR,<br>
Ulf W<br>
</blockquote></div><br>Bummer - I should have googled this a lot better before I wrote my own code.<br><br>Thanks for the tip,<br>Torben<br><br>