Version française
Home     About     Download     Resources     Contact us    
Browse thread
Run-time evaluation of a Printf format string
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jan Kybic <kybic@f...>
Subject: Run-time evaluation of a Printf format string
Hello,
        I would need an equivalent of Printf.sprintf where the 
format string is not constant, it is read from the command line.
The motivation is to let the user specify a template for file names,
such as "img%03d.png". Can this be achieved in Ocaml? It seems not, as 
Pervasives.string_of_format only accepts constant strings.
Or is there some external library useful for this task? 

For the moment I have started to implement it myself for the limited
set of format specifications I will need but if there is some more
elegant solution I would be interested to hear about it.

Thanks,

Jan

-- 
-------------------------------------------------------------------------
Jan Kybic <kybic@fel.cvut.cz>                       tel. +420 2 2435 5721
http://cmp.felk.cvut.cz/~kybic                      ICQ 200569450
D