/
CDC-1.2b/
CDC-1.2b/src/
parent $text
object $itext

var $root child_index 1
var $root owners [$itext]
var $root owned [$itext]
var $root fertile 1
var $text text ["hello", "this", "world"]
var $root inited 1
var $itext all_text #[["foo", [["hello", "world"], ""]], ["bar", [["hello", "this", "world"], ""]]]
var $itext current "foo"
var $root manager $itext
var $root writable [$itext]
var $root readable ['parameters, 'methods, 'code]
var $root dbref 'itext

method current
    return current;
.

method topics
    return dict_keys(all_text);
.

method set_desc
    arg desc, [topic];
    
    // set the description for a topic
    // The description is a short text string meant for use in an index
    // if <topic> is not given assume current
    topic = [@topic, current][1];
    if (topic in dict_keys(all_text))
        all_text = dict_add(all_text, topic, replace(all_text[topic], 2, short_desc));
    else
        throw(~topicnf, ("Topic " + topic) + " not found.");
.

method store
    arg [topic];
    
    topic = [@topic, current][1];
    if (!(topic in dict_keys(all_text)))
        all_text = dict_add(all_text, topic, [.text(), ""]);
    all_text = dict_add(all_text, topic, replace(all_text[topic], 1, .text()));
.

method set_current
    arg topic;
    
    current = topic;
    if (topic in dict_keys(all_text))
        .set_text((all_text[topic])[1]);
    else
        .set_text([]);
.

method get_topic
    arg topic, [who];
    
    if (topic in dict_keys(all_text))
        return (all_text[topic])[1];
    else
        throw(~topicnf, ("Topic " + topic) + " not found.");
.

method init_itext
    current = "";
    all_text = #[];
.

method get_desc
    arg topic, [who];
    
    if (topic in dict_keys(all_text))
        return (all_text[topic])[2];
    else
        throw(~topicnf, ("Topic " + topic) + " not found.");
.