Reputation: 9960
Wondering if it's possible to print a carriage return without a line feed in erlang? i.e. equivalent to printf("this will be replaced next time \r");
in C.
Had a look through the io:format() documentation and didn't see anything. It only seems to support ~n, equivalent to carriage return+line feed pair ('\n' in C).
Thx.
Upvotes: 3
Views: 2481
Reputation: 20936
You can use \r
in a string for the return character so:
io:format("Counter value: ~b\r", [Counter])
This is also works for character constants, $\r
, and in quoted atoms.
Upvotes: 4
Reputation: 2161
"\r" is a perfectly valid escape sequence in Erlang. So you can do just
io:format("\r").
Check the reference manual for other escape sequences.
Upvotes: 7
Reputation: 9960
Doh. Answer came almost as soon as I posted. ~c
enables printing of ASCII characters, so it's just a case of printing ASCII carriage return (13). e.g.
io:format("Counter value: ~b~c", [Counter,13])
Still interested in anything more elegant...
Thx.
Upvotes: 0