[Encore] Modified $recorder to show date and time in listings

Kevin Jepson kevijeps at telusplanet.net
Mon Sep 3 13:34:10 MDT 2007


Good Afternoon
I hope everyone is enjoying their Labour Day weekend :-)
The following code is a quick modification to the $recorder object in an
enCore V4 moo that shows the date and time when a recording was made.  It
makes use of the .date property on the note objects that the recorder uses.
The changes are mostly in the display verbs :tell_contents and :_html plus
one line in the :start_recorder verb to record the time on the .date
property.
In case this email doesn't format in a useable way I have posted the code at
the Barn so you can download it from here:
http://www.encore-consortium.org/Barn/news.html
I make no claims for elegance or efficiency here (or lack of errors for that
matter) and it seems to work but...
 caveat emptor. :-)
Enjoy
Ciao
KJ
=============
Modified verbs for the $recorder to display date and time recording was
started.
Always make sure you have a backup before making changes to base objects
like this.
--------------------------------------------
$recorder:start_recorder
 
"Routine that assigns a note to a recorder and turns the recorder on";
"Added record of the start date for each note in log.date";
"Used to list date and time in record listing. KRJ Sept 2, 2007";
if (caller != this)
  return E_PERM;
endif
log = this:create_note();
if (log != $nothing)
  string = ">> A red light on the " + this.name + " flashes to indicate that
it has been turned on and is now recording everything that is being said in
" + this.location.name + " <<";
  this.location:announce_all(string);
  this.log = log;
  this.recording = 1;
  this.log.text =  <mailto:{@this.log.text> {@this.log.text, "-- Start log:
" + $time_utils:time_sub("$D, $N $t, $Y $o:$M:$S $p ") + $network.MOO_name +
" time --"};
  this.log.text =  <mailto:{@this.log.text> {@this.log.text, ""};
  "record the time this recording started in the note's .date property";
  this.log.date = time();
else
  player:tell(">>> RECORDER NOT STARTED <<<");
endif
------------------------------------------------
$recorder:tell_contents
 
"Fixed spelling of Length :-)";
"Added listing of recording date and time. KRJ Sept 2,2007";
if (this.contents)
  su = $string_utils;
  n = 0;
  channel = this;
  player:tell("Contents:");
  player:tell("--- Title ---------------------- Length ---- Owner ----------
Date --- Time --");
  for thing in (channel.contents)
    $command_utils:suspend_if_needed(0);
    n = n + 1;
    timecode = thing.date;
    if (thing.date)
      timestring = $time_utils:time_sub("$2/$3/$y $H:$M$P", timecode);
    else
      timestring = "";
    endif
    size = tostr(length(thing.text));
    size = size + " lines";
    if (length(thing.name) > 30)
      title = thing.name[1..29];
      title = title;
    else
      title = thing.name;
    endif
    if (length(thing.owner.name) > 18)
      owner = thing.owner.name[1..17];
    else
      owner = thing.owner.name;
    endif
    player:tell(su:left(n, 4), su:left(title, 29), su:left(size, 12),
su:left(owner, 17), su:right(timestring, 15));
  endfor
 
player:tell("---------------------------------------------------------------
---------------");
endif
------------------------------------------------
$recorder:_html
 
"===========================================================";
"Copyright (C) 1995-2004, Jan Rune Holmevik and Mark Blanchard";
"Modified to include Date and Time of each recording, KRJ Sept 2,2007";
"===========================================================";
html = pass(@args);
user = args[1];
contents = {};
if (this.contents)
  titles = this.contents;
  titletxt = {};
  lengths = {};
  owners = {};
  for n in (titles)
    lengths =  <mailto:{@lengths> {@lengths, tostr(length(n.text), "
lines")};
    owners =  <mailto:{@owners> {@owners, n.owner.name};
    timecode = n.date;
    if (n.date)
      timestring = $time_utils:time_sub("$2/$3/$y $H:$M$P", timecode);
    else
      timestring = "";
    endif
    titletxt =  <mailto:{@titletxt> {@titletxt, timestring};
  endfor
  titles = $encore_web_utils:generate_links(user, titles);
  titles = {$encore_web_utils:div("Title", "header"), @titles};
  lengths = {$encore_web_utils:div("Length", "header"), @lengths};
  owners = {$encore_web_utils:div("Owner", "header"), @owners};
  titletxt = {$encore_web_utils:div("Recorded", "header"), @titletxt};
  titles = $encore_web_utils:insert_line_breaks(titles);
  lengths = $encore_web_utils:insert_line_breaks(lengths);
  owners = $encore_web_utils:insert_line_breaks(owners);
  titletxt = $encore_web_utils:insert_line_breaks(titletxt);
  contents = $encore_web_utils:generate_table(user, {titles, lengths,
owners, titletxt}, this, "1");
endif
html = $list_utils:append(html, contents);
return html;
------------------------------------------------
 
 
 
=======================================================
Kevin Jepson R.E.T.
President
4K Consulting Inc.                    
An't nanum hearm deth, doth hwaet ye willath.

PHONE: (403) 875-8372
Email: 4Kconsulting at gmail.com
            kevijeps at telusplanet.net
=======================================================
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://encore-consortium.org/pipermail/encore_encore-consortium.org/attachments/20070903/409b46a3/attachment.html 


More information about the Encore mailing list