I've got some of the os calls out of the Sandbox, as directed elsewhere on the site, which I've been using to append a time stamp to pages that get directed to a notepad window. I'm thinking I'd like to keep daily logs of these things using SaveNotepad. My only problem is that I can't figure out how to give each file a unique name based on the day -- something like "my_notepad - 2006-01-30.txt" -- while using the SaveNotepad function. os.date doesn't seem to work inside the SaveNotepad function, and putting the desired timestring into a variable doesn't work as the Notepad just spits out the variable name (such as "t") rather than the variable content.
Is there any good way of doing this?
I don't see why it wouldn't work, apart from coding errors. Can you please post your version, using os.date, that you say doesn't work?
Almost certainly it's my own mistake somewhere. I tried a number of things, but they're all variations of something like this:
t = os.date(%Y-%m-%d)
SaveNotepad("Game Log","c:/MUSH/MUSHclient/logs/Page Log - t.txt",0)
I'm guessing the problem is that I don't really understand how the os.date output gets put within the SaveNotepad function.
Oh. Lua has no idea that you're talking about the variable t and not the letter t. And that's a really good thing, actually -- otherwise it would replace the two t's in "txt" with your date!
Try:
SaveNotepad("Game Log","c:/MUSH/MUSHclient/logs/Page Log - " .. t .. ".txt",0)
instead. The .. operator is for string concatenation.
Ah-ha. I hadn't quite understood what the .. .. thing meant before. Thanks. :)
Also, os.date takes a string argument. Eg.
print (os.date(%Y-%m-%d)) --> Error: unexpected symbol near '%'
print (os.date("%Y-%m-%d")) --> 2007-01-31