On Mon, 26 Oct 2015, Summers, Peter wrote:
 Hi all,
 I've come across some (to me) odd behavior regarding how sprint 
 handles string substitution. I have several regressions that I'm 
 running in a loop, and I want to save the associated model table in 
 new file each time through. This seems like it should work (on 
 Windows 7, current snapshot):
 <hansl>
 list xlist = (names of relevant variables)
 vnames = varnames(xlist)
 loop foreach i xlist
 # run regressions, save to model table, etc.
 foo = vnames[i] # string with dependent variable name
 foo ~= ".tex"
 sprintf fname "C:\Users\psummers\Documents\my directory\%s", foo
 </hansl>
 However the sprintf command generates a syntax error ("sprintf: 
 unprocessed argument(s): 'foo'Syntax error"). If I replace the last 
 backslash with something else (eg a comma), it works fine. At the 
 moment that's my work-around (combined with using strsub to switch 
 the comma back to "\", of course).
 According to the user's guide, the "\" character isn't
"special" 
 within sprintf, but it seems to be causing some problems here. 
Backslash is special in printf and sprintf: it's the escape character, 
and it must be doubled to get a literal backslash. "\%" means a 
literal percent sign, which is why the 'foo' variable was rejected 
(there being no corresponding conversion specifier). If there's 
a statement to the contrary in the User's Guide, it's wrong.
As a general comment, you're better using forward slashes in 
filenames, even on Windows.
Allin