<!--
   $FML: create.sgml,v 1.3 2005/07/20 10:39:17 fukachan Exp $
   $jaFML: create.sgml,v 1.2 2003/04/15 14:51:42 fukachan Exp $
-->

<chapter id="module.create">
	<title>
	Execise: Create A New Program
	</title>


<para>
Consider creation of a simple scheduler listing tool in the &fml8;
framework. Here the program name is "fmlsch" and the cgi is
"fmlsch.cgi".
</para>


<sect1>
	<title>
	Case Study: Create A fmlsch
	</title>


<sect2>
	<title>
	Step 1: Add fmlsch Into Installer Configuration
	</title>

<para>
Prepare fml/bin/fmlsch.in, 
add fmlsch into $bin_programs in fml/etc/install.cf.in.
Run configure to re-create fml/etc/install.cf.
</para>

</sect2>


<sect2>
	<title>
	Step 2: Build A Module
	</title>


<para>
Write fml/lib/FML/Demo/Calendar.pm as the main library of fmlsch.
</para>

<para>
Import other libraries if needed. 
For fmlsch we import
HTML-CalendarMonthSimple-1.02.tar.gz
from CPAN.
See cpan/ directory.
</para>

<para>
Also, install Date-Calc if your system has not it.
</para>

</sect2>


<sect2>
	<title>
	Step 3: Modify FML::Process:: Class
	</title>

<para>
FML::Demo::Calendar works mainly. We need to prepare FML::Process
class for &fml8; bootloader to call FML::Demo::Calendar.
</para>

<para>
Firstly, write mandatory methods for fmlsch process in
fml/lib/FML/Process/Calender.pm. You need to create this file.
</para>

<para>
Secondly, set up boot loader configuration. In the case of fmlsch, the
bootloader loads FML::Process::Calender. Define it in fml/etc/modules. 
Set up fml/etc/command_line_options properly. This
"command_line_options" file has a map between a command and the
command line options parsed by Getopt::Long().
</para>


<para>
Create FML::Process::Calender module by copy-and-pasting other
FML::Process:: modules :-) Though fmlsch has only to contain least
functions, you need to write FML::Process::Calender::run() method.
For undefined methods, fml loads FML::Process::Kernel functions
(inheritence).
</para>

</sect2>

</sect1>


<sect1>
	<title>
	Case Study: fmlsch.cgi
	</title>


<para>
The way of hacking is similar to fmlsch. The differnce is the target
to modify, which is FML::CGI:: class. FML::CGI::Calender is a
sub-class of FML::Process::CGI.
</para>

<para>
If undefined method is called, fml loads it from FML::Process::CGI or
FML::Process::Kernel. FML::Process::CGI uses CGI.pm to create a http
header et.al. If FML::Process::CGI functions are not enough, FML::CGI
class module should support the lack.
</para>

</sect1>


</chapter>
