diff --git a/docs/mathex/Makefile b/docs/mathex/Makefile new file mode 100644 index 0000000000..1c8945c151 --- /dev/null +++ b/docs/mathex/Makefile @@ -0,0 +1,53 @@ +####################################################################### +# +# Makefile to compile all examples and convert them to LaTeX +# +####################################################################### + +# Compiler +PP=ppc386 + +# Unit directory +# UNITDIR=/usr/lib/ppc/0.99.0/linuxunits + + +# Any options you wish to pass. +PPOPTS= + +# Script to convert the programs to LaTeX examples which can be included. +PP2TEX=../pp2tex + +# Script to collect all examples in 1 file. +MAKETEX=make1tex + +####################################################################### +# No need to edit after this line. +####################################################################### + +ifdef UNITDIR +PPOPTS:=$(PPOPTS) -Up$(UNITDIR); +endif + +.SUFFIXES: .pp .tex + +.PHONY: all tex clean + +OBJECTS=ex1 ex2 ex3 + +TEXOBJECTS=$(addsuffix .tex, $(OBJECTS)) + +all : $(OBJECTS) + +tex : $(TEXOBJECTS) + +onetex : tex + $(MAKETEX) $(TEXOBJECTS) + +clean : + rm -f *.o *.s $(OBJECTS) $(TEXOBJECTS) + +$(OBJECTS): %: %.pp + $(PP) $(PPOPTS) $* + +$(TEXOBJECTS): %.tex: %.pp head.tex foot.tex + $(PP2TEX) $* diff --git a/docs/mathex/README b/docs/mathex/README new file mode 100644 index 0000000000..4796ee948c --- /dev/null +++ b/docs/mathex/README @@ -0,0 +1,8 @@ +These are the example programs that appear in the FPC documentation. + +Units guide, chapter on MATH unit : + +Example programs +ex1.pp contains an example of the arccos function. +ex2.pp contains an example of the arcsin function. +ex3.pp contains an example of the arcosh function. diff --git a/docs/mathex/ex1.pp b/docs/mathex/ex1.pp new file mode 100644 index 0000000000..5eac1fd2d5 --- /dev/null +++ b/docs/mathex/ex1.pp @@ -0,0 +1,20 @@ +Program Example1; + +{ Program to demonstrate the arccos function. } + +Uses math; + + Procedure WriteRadDeg(X : float); + + begin + Writeln(X:8:5,' rad = ',radtodeg(x):8:5,' degrees.') + end; + +begin + WriteRadDeg (arccos(1)); + WriteRadDeg (arccos(sqrt(3)/2)); + WriteRadDeg (arccos(sqrt(2)/2)); + WriteRadDeg (arccos(1/2)); + WriteRadDeg (arccos(0)); + WriteRadDeg (arccos(-1)); +end. diff --git a/docs/mathex/ex2.pp b/docs/mathex/ex2.pp new file mode 100644 index 0000000000..cdbd6206ea --- /dev/null +++ b/docs/mathex/ex2.pp @@ -0,0 +1,20 @@ +Program Example1; + +{ Program to demonstrate the arcsin function. } + +Uses math; + + Procedure WriteRadDeg(X : float); + + begin + Writeln(X:8:5,' rad = ',radtodeg(x):8:5,' degrees.') + end; + +begin + WriteRadDeg (arcsin(1)); + WriteRadDeg (arcsin(sqrt(3)/2)); + WriteRadDeg (arcsin(sqrt(2)/2)); + WriteRadDeg (arcsin(1/2)); + WriteRadDeg (arcsin(0)); + WriteRadDeg (arcsin(-1)); +end. diff --git a/docs/mathex/ex3.pp b/docs/mathex/ex3.pp new file mode 100644 index 0000000000..f2a3fc5fae --- /dev/null +++ b/docs/mathex/ex3.pp @@ -0,0 +1,10 @@ +Program Example3; + +{ Program to demonstrate the arcosh function. } + +Uses math; + +begin + Writeln(arcosh(1)); + Writeln(arcosh(2)); +end. diff --git a/docs/mathex/foot.tex b/docs/mathex/foot.tex new file mode 100644 index 0000000000..4b6c233a40 --- /dev/null +++ b/docs/mathex/foot.tex @@ -0,0 +1,2 @@ +\end{verbatim} +\end{FPCList} \ No newline at end of file diff --git a/docs/mathex/head.tex b/docs/mathex/head.tex new file mode 100644 index 0000000000..2699f37d16 --- /dev/null +++ b/docs/mathex/head.tex @@ -0,0 +1,3 @@ +\begin{FPCList} +\item[Example] +\begin{verbatim} diff --git a/docs/mathex/newex b/docs/mathex/newex new file mode 100644 index 0000000000..45f07f89e7 --- /dev/null +++ b/docs/mathex/newex @@ -0,0 +1,8 @@ +#!/bin/sh +if [ -e ex${1}.pp ]; then + mv ex${1}.pp ex${1}.pp.orig +fi +sed -e s/Example/Example$1/ -e s/\\\*\\\*\\\*/$2/ ex${1}.pp +echo "ex${1}.pp contains an example of the $2 function." >>README +joe ex${1}.pp +ppc386 ex${1}.pp && ex${1} diff --git a/docs/mathex/template.pp b/docs/mathex/template.pp new file mode 100644 index 0000000000..b4f5782589 --- /dev/null +++ b/docs/mathex/template.pp @@ -0,0 +1,8 @@ +Program Example; + +{ Program to demonstrate the *** function. } + +Uses math; + +begin +end.