|
prestojosh Beginner
Joined: 21 Feb 2006 Posts: 19
|
Posted: Fri Apr 07, 2006 2:34 pm
Tell log to database or log file and recall |
Heres what I'm thinking an alias to turn on a triggerset for tells so when they come it will timestamp and put them in a db/log file and when you have the command to return it will feed them to you or open the log that they are timestamped for. I realize there are tell loggers to seperate windows but another window for it is too annoying. If anyone could tell me how to do this that would be just great.
Pattern (%w) tells you '(*)' |
|
_________________ -Presto |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Apr 07, 2006 8:47 pm |
if you aren't going to use another window, I believe you are limited to #WRITE. For that you need to specify the filename and number using #FILE, like so (use the helpfile to verify syntax):
#FILE 1 "name.txt"
You then have acess to the file for reading and writing. You'd handle this in whatever triggers you have for speech:
#write 1 "what you want to write"
"what you want to write" is completely optional IF you aren't going to mess with it, but since you want to also add a timestamp you need to use %concat() to properly build your string:
%concat("[",%time("h:nn:ss ampm"), "] ", "what you want to write")
At some point you want to stop logging, so you need to use the #CLOSE command to close and save the file:
#CLOSE 1
In all cases, 1 refers to the actual file number, and can be anything from 1-5 (for simple sequential files, which store data "all on one line each time you write to the file") or 6-10 for fixed-length record files (which are the precursors of the database, storing data in delimited records "like, this, here") |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
prestojosh Beginner
Joined: 21 Feb 2006 Posts: 19
|
Posted: Sat Apr 08, 2006 3:20 pm |
Okay so I have it to log to the text file but how can I make the alias when I come back to read it back into my window and delete the file or clear it out?
I tried #READ but it just sits there. |
|
_________________ -Presto |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Apr 08, 2006 7:30 pm |
You don't want to use #READ, unless you prepending every #WRITE with a #SAY or something to prevent it from getting sent to the mud. Use %read() instead:
#alias InstantReplay {#file 1 "whatever";Line1 = %read(1);Line2 = %read(1);#while ((@line != "") and (@line2 != "")) {#say %concat(@line1,%cr,@line2);line1 = %read(1);line2 = %read(1)};#close 1}
The above use of two line variables should ensure that blank lines before the EOF mark don't prematurely end the loop, and at the same time allowing you to keep your file humanly readable. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|