Gammon Forum
Entire forum
MUSHclient
Lua
Appending date strings to saved notepads
Appending date strings to saved notepads
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Balerion
(18 posts) bio
|
Date
| Tue 30 Jan 2007 05:24 PM (UTC) |
Message
| 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? | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Tue 30 Jan 2007 06:50 PM (UTC) |
Message
| 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? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Balerion
(18 posts) bio
|
Date
| Reply #2 on Tue 30 Jan 2007 10:16 PM (UTC) |
Message
| 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. | top |
|
Posted by
| David Haley
USA (3,881 posts) bio
|
Date
| Reply #3 on Tue 30 Jan 2007 11:02 PM (UTC) |
Message
| 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.
|
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|
Posted by
| Balerion
(18 posts) bio
|
Date
| Reply #4 on Tue 30 Jan 2007 11:05 PM (UTC) |
Message
| Ah-ha. I hadn't quite understood what the .. .. thing meant before. Thanks. :) | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #5 on Wed 31 Jan 2007 03:23 AM (UTC) |
Message
| 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
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,648 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.