pretty printing of records

Inswitch Solutions erlang@REDACTED
Wed Aug 10 15:11:03 CEST 2005


Surely not the best way but I print records like this:

%% function to expose each record info
getFields(myRecord) ->
           record_info(fields, myRecord);
...

%% the record output in "field......value" format
makeResponse([], [], StrResp) ->
 StrResp;
makeResponse([F|Fields], [V|TValues], StrResp) ->
 Fld = io_lib:format("~p......................", [F]),
 Str = io_lib:format("~20s: ~p\r\n", [Fld, V]),
 makeResponse(Fields, TValues, StrResp++Str).

Hope it helps you, Eduardo

----- Original Message -----
From: "olivier" <olivier@REDACTED>
To: "Ulf Wiger (AL/EAB)" <ulf.wiger@REDACTED>
Cc: "Mikael Karlsson" <mikael.karlsson@REDACTED>;
<erlang-questions@REDACTED>
Sent: Wednesday, August 10, 2005 9:44 AM
Subject: Re: pretty printing of records


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> Hello,
>
> Speaking of pretty-printing, I'd like to submit a feature request
> for the "tv" module of erlang:
>
> I recently patched tv_io_lib.erl to "view binaries as strings", as
> I store binaries in Mnesia that are printable. That could be an
> addition to "view lists as lists/strings", what do you think ?
>
> Cheers,
>
> - --
> Olivier Girondel <olivier@REDACTED>
> Project Leader
> Dolphian
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFC+fbGpqVXaJzJYNIRArLEAKCEMZkxsSyo367FqLkPECWhpPxOowCffAQS
> Nv4beW/kRdlw29QIzwIrcPc=
> =az71
> -----END PGP SIGNATURE-----
>





More information about the erlang-questions mailing list