How to Automatically Remove Part of Title for Use in Attribute

I have a prototype called “口頭のインプット,” for which I use for my blackboard stories, cartoons, read-alouds, etc containers. Now, for the cartoon container which I call “教育番組”, I have a special edict as shown below.

if($Name(grandparent)==“教育番組”){$Series=$Name(parent);$Type=$Name(grandparent)} else {$Type=$Name(parent)};

As can be seen, I stick names of series in the “教育番組” container, and I add names of episodes in the container of said series. In the notes for episodes, I want to pull in $Type(grandparents) and $Series(parent). If the title of a note is, for example, KBG- Sesame Street, how can I make it so that only Sesame Street appears in the attribute for an episode note?

I saw that there was a .replace function in a thread for exploding notes, but I don’t know how to put the two together, especially when referencing to a generic “parent”.

Let me make a tiny example, just to be sure we’re all on the same page.

Educational Programs
    Sesame Street
        S53E17 Just Right
        S53E18 Art Rocks

In this framework, the edict inherited from our prototype becomes

} else {$Type=$Name(parent)};

For example, for the note for “Art Rocks!”, $Series would be “Sesame Street” and the $Type would be “Educational Programs”.

Am I roughly correct so far?

That’s right!

And your question, if I understand it, is “The actual name of $Series(parent) is “KGB-Sesame Street. I want to strip out the 'KGB- '”.

There are several ways you might want this to work. One might be,

if($Series=="KGB- Sesame Street") { $Series="Sesame Street";}

Another might be “eliminate the KGB- prefix whenever you find it.

if($Series.beginsWith("KGB- ")) { $Series=$Series.substr(4);}

This would turn “KGB- Sesame Street” into “Sesame Street”, but leave “Tales Of The KGB- uncensored!” unchanged. (.substr()) means “substring” — in this case, it skips the first four letters of the $Series and returns the rest.)

Yet another might be “Replace 'KBG- ’ wherever you find it.

$Series=$Series.replace("KGB- ","");

As you see, there are lots of ways to do this sort of thing.


I see! I am still trying to get the hang of coding in tinderbox (and coding in general). I don’t know why I didn’t think of just creating if statement that uses the abbreviation of the note instead of referring to a generic parent/grandparent note in the edict. I greatly appreciate your help!

A handy Web-based listing of Action code operators is here: Full Operator List. You’ll see there are a lot of operators such as .substr() designed for string (i.e. text) manipulation.