# Use version 2.00 extensions to the stt
#
//VERSION 2.00

# short title string, used in listings
#
//TITLE A sample text template

# Full description of the template
#
//DESCR
This is a sample template, that tries to show many possibilities
of the standart text tool.
/*

# Definition of all variables
#
#     name      reply-deriv             default
#
//VAR toname	"repl-name"		"Anonymous"
//VAR toaddr	"repl-addr"		"anonymous@ftp.site.somewhere"
//VAR header	"rfc822"		""
//VAR cc	"cc"			""
//VAR body	"body/20L"		""
//VAR myname	""			"BUILTIN"
//VAR username	""			"BUILTIN"
//VAR signame   ""			"BUILTIN"
# Declare some variables for fun
//VAR color	""			"3"
//VAR choice	""			"yes"
# Multiline default
#
//VARMULTI optional			""
$friendly had a choice from red, yellow, orange, green, blue, 
indigo and violet.
/*

# Prompt strings (descriptions) of the variables
#
//PRO toname    "Name of the recipient"
//PRO toaddr    "Mail address of the recipient"
//PRO color	"What color do you prefer"

# Make selection from the list of possible choises
#
//SELECT color
Red
Yellow
Orange
Green
Blue
Indigo
Violet
/*

# Variables to be taken from the command line (in this sequence)
#
//ARGS toname toaddr color

# Variables to be prompted (in this sequence)
#
//ASK toname toaddr color

# Derivations of variables
#

# Initialisation
#
//CODEINIT
# Just to show we can do this
use Carp;

# Declare lexical variable
my $friendly;
/*

# Main code
#
//CODE
# Lets ask if optional info should be shown
my $prompt = "Would you like to show optional info(Y/N)";
# Correct respond should start from Y(es) or N(o)
$choice = prompt($prompt, $choice, sub { $_[0] =~ /^[YN]/i; });

# Uppercase of the selected color
$color = uc($color);

# Uppercase the first letter of the username
$friendly = ucfirst($username);

# Make a nice quoted body
if($body)
    {
    $body =~ s/^(.*)$/> $1/gm;
    }
/*

# conditional text
//OTEXTCOND optional
if($choice =~ /^Y/i) {
    my $prompt = "Are you REALLY sure you want to show optional info(Y/N)";
    $choice = prompt($prompt, 'no', sub { $_[0] =~ /^[YN]/i; });
    # Return true if the answer was Y(es)
    return($choice =~ /^Y/i);
    }
return 0;
/*

# The template text itself
#
//TEMPLATE
To: "$toname" <$toaddr>
Cc: $cc
From: "Nowhere man" <noone@nowhere.no>
Subject: Greetings to $toname
Reply-To: <devnull@localhost>
X-Location: Nowhereland

Dear $toname,

We would like to inform you that $myname (for friends
just $friendly) prefers $color to any other colors.

$optional

Once upon a time $toname wrote this to $myname:
> 
$body
---------
Sincerely yours,
$signame
/*

# We sent mail!
#
//POSTSENT
print STDERR "Message was sent successfuly to $toname.\n\n";
/*

# Mail wasn't sent
#
//POSTNOTSENT
print STDERR "Message was not sent!\n\n";
/*

