Re: [eclipse-users] sprintf?

From: Kish Shen <kisshen_at_cisco.com>
Date: Mon, 27 Aug 2007 19:24:06 +0100
HiWarwick,

Warwick Harvey wrote:
> Hi Kish,
>
> This seems to come up often enough that I think it's worth putting into
> ECLiPSe.  Is there any reason why it shouldn't go in, other than the fact
> that I'll then have to remove its definition from half-a-dozen projects I've
> worked on?  ;)
>
> Here's the (obvious) definition I use:
>
> sprintf(String, Format, Args) :-
> 	open(string(""), write, Stream),
> 	printf(Stream, Format, Args),
> 	get_stream_info(Stream, name, String),
> 	close(Stream).
>
> Cheers,
> Warwick
>   
How do you use this predicate? If you are creating a string that is made 
up of atomic terms, it is
probably easier to use concat_string/2. I can see it being useful for 
printing formatted terms, but
do you want to put this into a string often?

Cheers,

Kish
Received on Mon Aug 27 2007 - 19:24:31 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET