return to teapro.com
----------------------------------------------------------------
The Teapro Computer Programming Language Written in C90

A Collection of Short Articles on Teapro and OpenTea

05-FEB-2014

Copyright (c) 2004-2014 by D La Pierre Ballard

This webpage and research are purely for educational purposes.



Teaquad Method is copyright (c) 2006-2014 by D La Pierre Ballard

People need computer software that actually works.

"Eschew Obfuscation!", sign held by noted math educator John Saxon
(1923-1996) at the Medieval Fair, Norman, Oklahoma, Spring 1983.
----------------------------------------------------------------
Please feel free to quote or copy from this webpage. Also, feel
free to link to this webpage.
----------------------------------------------------------------
What is teapro.exe?
The teapro.exe computer program is an interpreter for the
computer programming language Teapro. The teapro.exe program is
written in C90 which is generally regarded as the most portable
programming language that is compiled. The website teapro.com
has teapro.exe as a free download. The source code for the
Teapro interpretor, teapro.c, is available for free also on the
website teapro.com and may be compiled for Windows or Linux or
the Mac OS X operating system.
----------------------------------------------------------------
Suppose you need a quick program to do some file processing or
maybe some terminal input/output with calculations all on a
Windows, Linux or Mac OS X computer. Teapro will do the job. A
quick Teapro program is easy to write and debug. There is a lot
less to go wrong with a Teapro program. Teapro is a no frills
language which is often easier and more solid to work with than
other interpreted languages. Teapro has been designed from the
start to be simple and solid. The Teapro interpreter is
available at teapro.com. It is available in source code as
teapro.c or as a ready to run executable teapro.exe for Windows.
----------------------------------------------------------------
The computer programming language Teapro may be used for free
by anyone, but there is no warranty of any kind whatsoever on
Teapro.
----------------------------------------------------------------
The computer program teapro.exe may be used for free by anyone,
but there is no warranty of any kind whatsoever on teapro.exe.
----------------------------------------------------------------
The computer source code teapro.c may be used for free by
anyone, but there is no warranty of any kind whatsoever on
teapro.c.
----------------------------------------------------------------
The computer source code tinytea.cpp may be used for free by
anyone, but there is no warranty of any kind whatsoever on
tinytea.cpp. The program tinytea.cpp is the beta version of the
next version of teapro.c and has the .cpp ending because it is
usually compiled on a C++ compiler.
----------------------------------------------------------------
The Teaquad method for testing numbers from 1E15 to 1604E18 for
primeness may be used for free by anyone. There is no warranty
of any kind on the Teaquad method.
----------------------------------------------------------------
----------------------------------------------------------------
The program teapro.exe interprets the Teapro computer
programming language. Teapro is a simple programming language
which runs on Windows, Linux or Mac OS X. The complete C90
source code for Teapro is available as a free download from
teapro.com as teapro.c which can be compiled for Linux or Mac OS
X, also. Teapro does have full file, decimal number and string
processing. Because Teapro is available for free there is no
expense in obtaining it. The single file teapro.exe, which is
the Teapro interpreter program for Windows, is all you need to
add to your Windows computer to allow you to run programs
written in the Teapro language. The Teapro interpreter,
teapro.exe, is available for free download from the website
teapro.com.

The Teapro programming language is a simple and solid
interpreted language which runs on Windows, Linux or Mac OS X
using one single stand alone interpreter program. The Teapro
interpreter can be installed in a directory by merely copying it
to that directory from a diskette, a network or the Internet.
The Teapro interpreter program can be uninstalled merely by
deleting the one file from your computer. The Teapro intrepreter
program is small enough so that you can even run it off of a
diskette. Since the Teapro interpreter is written in standard
C90 it can be compiled and run on Linux or Mac OS X in the same
way after compiling it with the gcc compiler on Linux or Mac OS
X. For Windows that file is teapro.exe available for free
download from teapro.com.

The Teapro programming language has very powerful string,
number and file handling capabilities as well as simple control
structures which allow complex programming to be done easily.
Teapro uses technologies developed in the past which were too
slow then, but which are viable on the much faster Personal
Computers of today. Teapro uses the OpenTea technology for
programming that is simple and solid.

The Teapro programming language was invented on 14-DEC-1997 by
D La Pierre Ballard. The Teapro interpreter, teapro.exe, was
written by him in C90 and is a full 32-bit Windows application.
The available source code in teapro.c can be compiled and run on
Linux or Mac OS X in exactly the same fashion. A Teapro program
is a text file with the extension .TEA and can be coded using
any word processor or text editor. If the programmer prefers,
the .TXT extension works fine too.

Teapro was developed to show that effective programming
can be done on Windows, Linux or Mac OS x without having a
development system consisting of hundreds of files and
costing a hundred dollars or more. Teapro is enormously
simpler than any of the major languages in use today and
is slower only because it is strictly interpreted. Teapro
has far fewer gimmicks in it than do other languages.
Teapro does not allow the programmer to use any of the
constructs which tend to over-complicate so many of the
modern programs. Those are the same programs which are
hard to understand, hard to fix and full of minor bugs.

Teapro uses the OpenTea technology of far greater simplicity
than has been generally used in the past for computer
programming. Teapro does not access the internet. System
commands cannot be called in Teapro. Other programs cannot be
started by a Teapro program. Teapro has definite limits to make
it immune to viruses and attacks by malevolent software. Teapro
is much more solid than most other software. Teapro does not
access the computer's registry or configuration files.

The author realizes that many programmers will not find Teapro
attractive because of the limitations of the Teapro language
which require a much simpler programming style than other
languages. The author hopes to show that the current trends in
programming toward the bigger and more complicated are neither
necessarily needed nor good. Teapro greatly limits the
programmer to structured programs containing simpler constructs
that are easy to understand and maintain. Of course, Teapro does
now include the goto, gtag commands which can be used for
non-structured programming. Read the chapter on the goto, gtag
commands.

From teapro.com is available for free download the Teapro
interpreter written in C90 for Windows as teapro.exe. Also,
there is a obsolete Teapro interpreter written in Borland Delphi
2.0 for Windows named teapro9.exe. Additionally, the C90 source
code for the Teapro interpreter is available for free download
as teapro.c which can be compiled for Linux or Mac OS X.
----------------------------------------------------------------
----------------------------------------------------------------
Traditionally, the first program that a newcomer to a
programming language does is the "HELLO WORLD" program. Let us
do it in Teapro.

First, download the Teapro interpreter, teapro.exe, to your
computer from the website teapro.com. You might want to create a
special folder to hold it along with any programs in Teapro you
might write.

Second, open whatever wordprocessor you prefer or even Notepad
or Wordpad that come with Windows.

Third, type into that word processor the following short seven
line program. Which is listed between the dash lines. Teapro is
not sensitive to case so you can use uppercase, lowercase, or
mixed as you prefer.
----------------------------------------------------------------
sub_helloworld
endp
subr sub_helloworld
   vari s_any
   $out "HELLO WORLD"
   $inp s_any, "return"
ends sub_helloworld
----------------------------------------------------------------
Next, save the program in the same folder that contains the
Teapro interpreter program, teapro.exe. Save the HELLO WORLD
program as HELLO.TEA and save it as a text file. You can also
save it as HELLO.TXT, if you prefer.

Next, run the Teapro interpreter, teapro.exe, that is in that
same folder.

Next, type in the console command LOAD and hit return.

It will ask for the program name. Type in HELLO.TEA or
HELLO.TXT, which ever you named the small Teapro program.

Next, type in the console command RUN and hit return.

This will run the Teapro program HELLO.TEA which you have just
written. The following two lines should appear on the Teapro
console display:

HELLO WORLD
return

The word "return" is to prompt you to hit the return key on
your computer. When you do so the Teapro program HELLO.TEA will
end. You can type in an asterisk and hit return to close the
Teapro console. You have just run your first Teapro program.

In the next chapter there is a line for line explanation of the
seven line Teapro program HELLO.TEA.
----------------------------------------------------------------
----------------------------------------------------------------
This chapter gives a line for line explanation of the Teapro
program HELLO.TEA which does HELLO WORLD. Here, again, is that
seven line program between the dash lines.
----------------------------------------------------------------
sub_helloworld
endp
subr sub_helloworld
   vari s_any
   $out "HELLO WORLD"
   $inp s_any, "return"
ends sub_helloworld
----------------------------------------------------------------
Below is a line for line explanation of the above program.
----------------------------------------------------------------
sub_helloworld

The above line calls the subroutine sub_helloworld.
----------------------------------------------------------------
endp

The above line ends the program after the subroutine
sub_helloworld is called and returned from.
----------------------------------------------------------------
subr sub_helloworld

The above line is the first line of the subroutine
sub_helloworld.
----------------------------------------------------------------
   vari s_any

The above line defines a string variable s_any which can be
used within the subroutine sub_helloworld.
----------------------------------------------------------------
   $out "HELLO WORLD"

The above line outputs a string to the screen. The string is
"HELLO WORLD". The quotation marks are not part of the string
but only delineate it.
----------------------------------------------------------------
   $inp s_any, "return"

The above line outputs the string "return" to the screen and
waits for the user to hit return or enter something in and hit
return. Whatever the user enters in is put into the string
variable s_any.
----------------------------------------------------------------
ends sub_helloworld

The above line ends the subroutine sub_helloworld. The next
line after calling the subroutine is then performed which ends
the Teapro program.
----------------------------------------------------------------
----------------------------------------------------------------
In Teapro, the only reserved words are the Teapro commands
which are well covered alphabetically in other chapters in this
booklet.

The language Teapro has only two variable types. It has strings
and decimal numbers. Strings are strings of characters of any
length up to 100,000,000, if the memory of your computer will
handle them that big.

Decimals are fifteen digit accuracy floating point decimal
numbers which can be plus or minus and either quite large or
quite small. Of course, the floating point decimal numbers have
the same limitations in Teapro that they have in other
languages. Sometimes decimals in Teapro can have sixteen digit
accuracy. See the chapter on Teapro floating point decimal
arithmetic.

Teapro has a fantastic assortment of commands for handling
strings. For example you can cut, delete, insert or replace
characters in the middle of a string. You can do lookups
starting at any certain point in a string that go forwards or
backwards. You can sort the constant length substrings which
make up a string. You can test a string to see if it is all one
character or fits a certain pattern or is numeric.

In Teapro there are restrictions on the naming of variables
which make it obvious to the programmer which data type the
variables are. Other languages do not have this and it is often
difficult to tell reserved words from variables. Additionally,
because of these restrictions in Teapro, it is also obvious
whether or not a variable is a global variable or a local
variable. Also, variable names that overlap other variable names
within the same subroutine are not allowed in Teapro. You cannot
have local variables named s_string and s_string1 both in the
same subroutine because they overlap.

In Teapro you can have global variables and local variables.
This has been one of the greatest advances of modern
programming. Other languages do this in ways far more complex
than in Teapro. There are no pointers in Teapro.

The OpenTea methods of file processing are used in Teapro. File
processing is done much simpler in Teapro than in other
languages. In Teapro there are three ways to read files and to
write to files. In each of the three ways, the file is opened
and closed by each read or write command. In this way there is
no limit on the number of files accessed. Also, a program crash
has far less chance of damaging a file this way, since most of
the time no file is open. The name of the file must be included
in each read or write command in a string variable. Because of
this, it is obvious which file is being processed. Some may say
that this method is too slow. However, modern computers are so
fast that an interpreted language such as Teapro is now viable
which offers this much higher degree of simplicity and solidity.

The first of the three ways to read and write files is with the
commands frea and fwri. These commands read and write by byte
position in the file and by length. These commands are best for
random access of fixed length records.

The second file access method in Teapro is with the commands
fsip and fapp. These commands are for reading and writing lines
which are variable length records which end in a carriage return
and a line feed. These commands are used to read through a text
file or to write one.

The third method of file access in Teapro is with the commands
finp and fout. These two commands read and write an entire file
into or from a single string variable all in one swoop.

All Teapro commands are four characters long. The beginning
character in many cases is either $ or D depending upon which
type of variable the command uses. The commands which do not
begin with $ or D are mostly commands used for control, file
processing, array access, or to set up variables.

Without using the goto and gtag commands, it is impossible in
Teapro to write an unstructured program. You cannot exit a
subroutine except by exiting at the bottom. There is no
"CONTINUE" command to go to the top of a loop block before
hitting the endw command. The is no "BREAK" command to jump to
the bottom of a loop block or a dift/$ift block.

The goto and gtag commands were added because Teapro was being
used to write a program to translate from a language in which
goto and gtag equivalents were used into Teapro. In certain
cases, the goto and gtag commands make for a much simpler and
much faster program than using the dift, $ift, dwhi, $whi
commands even with deeply nested subroutines.

There can be no memory leaks in Teapro because you cannot
allocate memory as in other languages in which you must then
remember to deallocate it. If you need space in which to store
data, you can put a whale of a lot in a string.

The Teapro interpreter is a single .EXE Windows file well under
a 200K in size. Teapro can be put on any Windows computer by
merely copying it from a diskette. The source code in C90 for
the Teapro interpreter compiles and runs similarly well on Linux
computers. The Teapro interpreter uses a remarkably low level of
resources to run so that it can run while many other
applications are running also.

To run a Teapro program on Windows you need only the Teapro
interpreter, teapro.exe, and the one Teapro program file that
you want to run. You do not need dozens of other files, and you
do not need to install anything. A standard 1.44 Meg diskette
can well hold both the Teapro interpreter and several Teapro
programs with plenty of room to spare. The Teapro interpreter
can run a Teapro program just fine even when both are on a 1.44
Meg diskette. A Teapro program file is a text file that has the
extension .TEA as the last part of the name of the file. If you
prefer, you can use the extension .TXT instead.

Interpreted languages are proving to be a major direction that
computer programming is turning to more and more often. Programs
written in them are much easier to modify and rerun. Interpreted
languages generally offer far more simplicity than compiled
languages and offer commands that accomplish much more. Some
interpreted languages are for internet use; whereas, some are
for the purpose of controlling the computer. Teapro does not do
those things but is best suited for file processing,
calculations, and terminal input and output.
----------------------------------------------------------------
----------------------------------------------------------------
The OpenTea technology of simple and solid programming which is
used in Teapro is discussed in the following paragraphs.

Teapro does not have the graphical user interface that has
taken the world by storm. The GUI, as it is called, is often
unnecessary and just costs heavily in terms of system resources.
Teapro is best for calculations, file processing, and screen
input and output. The command line interface of Teapro offers
much greater flexibility for complex program input than does a
GUI. A graphical user interface would be of minimal value for
this type of programming.

Teapro is not object oriented, but is an old fashioned
procedural language. What the object oriented languages offer is
far too complex when simple programs of just a few thousand
lines are needed. One slight disadvantage of Teapro is that it
does not allow subroutines to be defined within subroutines.

Teapro does not have multi-threading. Multi-threading is
sometimes useful for compiled commercial applications, but is
otherwise more trouble than it is worth. In application
programming it is not necessary.

In Teapro you cannot combine several commands into one command.
There are no functions and the programmer in Teapro can only
write subroutines not functions. Languages which have functions
sometimes have problems with whether or not a function is
called. The languages which have functions sometimes limit what
may or may not be done within a function.

The order of the variables following an assignment command
determines the order in which the aritmetic is done. The
arithmetic is done strictly left to right. This is far simpler
for the programmer to understand than in other languages in
which the assignment command is really an algebraic equation to
be solved. This left to right method of performing assignment
commands is far simpler for the programmer and for the
interpreter. The left to right evaluation of an expression is
much more likely to give the programmer the expected answer.

In Teapro, variables must be passed to subroutines and from
subroutines using generically named global variables. By doing
this in this fashion it is obvious to the programmer whether or
not the called subroutine changes the original sent variable or
not. This is more like the way information is actually passed
between subroutines in other languages where the actual process
is disguised by the complex parameter notation.

Generically named global variables are just global variables
named with names like sg_pass1, sg_pass2, dg_pass1 or dg_pass2
which are used for passing data to and from subroutines.

In Teapro, just prior to calling a subroutine, you must put the
non-global variables, which you want to pass to that subroutine,
into generically named global variables. At the bottom of the
subroutine if you want to pass data back to the code which
called that subroutine you must put that data into generically
named global variables. Since Teapro is a generally structured
language, code in subroutines is performed from top to bottom so
that it is simple to send variable values back to the calling
subroutine using global variables. Usually some global
generically named variables of both data types are defined at
the beginning of the program to be used for this passing of
information.

In Teapro all global variables are statically allocated when
the program is prepped just prior to execution. Local variables
are dynamically allocated just as in other modern languages.
Because the local variables are dynamically allocated during
execution, recursive subroutines may be used if the programming
problem requires this. It is only necessary to remember to use
global generic variables to pass data to and from the performing
subroutine.

In other interpreted languages the original code is usually
compiled into either a pseudo-code or byte codes and can only be
made sense of by the language interpreter or virtual machine.
With Teapro the actual written text code is the program that the
interpreter reads in to perform. When the Teapro interpreter
begins to run a program, it goes through and makes a few changes
to the code in its own memory to make interpretation much
simpler and faster.

The fact that anyone can read through the actual text Teapro
program is both an advantage and a disadvantage. If the
progammer needs to keep his work secret it is a disadvantage.
Because the source program is also the object program. The
OpenTea technology prefers open source code.

Once the Teapro interpreter begins running a Teapro program,
the actual text file which contains the program is no longer
being accessed by the Teapro interpreter. At that time the
Teapro interpreter only needs the Teapro program which it has in
memory to continue to run that Teapro program.

Because Teapro is interpreted and has deliberately built in
limitations, it is sometimes called a scripting language. Teapro
is limited to file processing, heavy string processing, keyboard
input and output and intensive mathematical calculations. It is
these types of computer processing that Teapro is designed to
do. Teapro does not have commands that can be used to take
control of your computer. Viruses cannot be written in Teapro
because programs written in Teapro cannot call other programs or
call operating system commands.
----------------------------------------------------------------
----------------------------------------------------------------
Here is further discussion of how the OpenTea technology is
utilized in Teapro.

1. Teapro programs are generally structured programs.
Subroutines are entered at the top and exited at the bottom. If
absolutely necessary the programmer can use the commands goto
and gtag to jump around when absolutely needed.

2. Variable names in Teapro must utilize a hungarian type of
notation. From a variable name the programmer can tell not only
the type of the variable but also whether the variable is global
or local.

4. Teapro has strongly typed variables. Teapro commands require
that the parameters be either string or decimal types. Only
string expressions will allow either type of variable.

5. String append expressions are only allowed when doing a
string assignment or with the commands $app, $inp, $out, and
$sho.

6. Decimal variable expressions are allowed only when doing a
decimal variable assignment. Decimal assigment statements are
performed strictly left to right.

7. Subroutine names always begin with "sub_". In Teapro there
is no confusion between subroutine names, Teapro command names
and variable names.

8. There are no functions in Teapro and the programmer can only
write subroutines.

9. Data is passed by generically named global variables when
going into or coming out of subroutines.

10. The conditional control commands: dwhi, dift, $whi and
$ift, can each do only one compare for each command.

11. The right side of a numeric decimal assignment command is
evaluated strictly left to right, not according to operator
precedence. It is not an algebraic expression as in other
languages. Algebraic expressions are not used in Teapro.

12. There are less than one hundred keywords in Teapro.

13. File processing using the frea, fwri, finp, fout, fsip, or
fapp commands to read or write to a file has the name of the
file in a string variable as one of the parameters of those
commands. The file is opened, processed and then closed. No file
is left open from one command to another.

14. Except for $ift or dift command lines followed by a colon
and a non-control command, there can never be more than one
command per line. Command lines beginning with $ift or dift when
followed by a colon allow one other command on that line and do
so because the performance of that one other command is
conditional. That other command may not be a control command.

15. Blank lines, comment lines, spaces between command
parameters, indentation and uppercase/lowercase can all be used
according to the programmer's style. These things do not affect
the speed or the resources of the running program in any way.

16. Program lines may not be wrapped to the next line. The
whole command line must be on one line.
----------------------------------------------------------------
----------------------------------------------------------------
A Teapro command must be only on one line. However, spaces may
be put in between the parameters of the command to make the
appearance easier to read. These spaces do not affect the speed
of the program.

Comment lines may be put anywhere and are begun with an
apostrophe. Comment lines do not affect the speed of the
program.

Blank lines can be put where wanted and do not affect in any
way the use of resources or the speed of the program.
----------------------------------------------------------------
Generally, a Teapro program starts out with some lines defining
the global variables wanted. Then may follow some lines in which
some subroutines are called. Since local variables can only be
defined in subroutines, the Teapro programmer may want the call
to a subroutine to be the only non-subroutine command other than
to define some global variables. In that way all other
processing will be in subroutines which have local variables
available.

Each time a subroutine is entered all of the local variables
for that subroutine are initialized to zero for decimal
variables or to a string of zero length for string variables.
----------------------------------------------------------------
Command names in Teapro generally have movement from left to
right. However, command parameters have movement from right to
left. For example, take the following command:

$tod d_decimal, s_string

The command name is: string to decimal. This command takes the
value of the string s_string, and it converts that value into a
decimal number value and then stores it in the decimal variable
d_decimal. Movement in the command name, $tod, is from left to
right. Movement in the parameters is right to left. This
convention in Teapro, which nearly always applies, helps the
programmer to remember the commands and the parameters of the
commands.

In the assignment command there is no command named. However,
the right side of the assignment command moves to the left after
it is evaluated. For example:

d_decimal1 = 5 + d_decimal2 * d_decimal3

We take 5 and add d_decimal2 to it. Then we multiply that
decimal number by d_decimal3 and store the result in d_decimal1.
The evaluation of the decimal expression to the right of the
equal sign is left to right, but the movement is still right to
left since the value of that decimal expression is moved from
the right to the left into d_decimal1.

Teapro programs are text files with the program name having
extension .TEA and can be written or coded using any word
processor or text editor. Some programmers may prefer to have
the extension .TXT on the Teapro program, and that will work
fine, too.
----------------------------------------------------------------
----------------------------------------------------------------
The aim of the OpenTea Technology which Teapro utilizes is to
have a language which is simple and solid.

Reliability and trustworthiness are the other keywords kept in
mind besides ease of use and simplicity during the development
of the language Teapro and during the writing of the Teapro
interpreter.

The Teapro interpreter does not try to access the internet and
does not install software on the user's computer. Because Teapro
does not offer a means to do calls to the operating system,
there is no way that any kind of virus, worm, or trojan can be
written in Teapro.

There are no problems with buffer overflow with the Teapro
interpreter like some other software. Any extreme or excessive
string sizes will cause an error condition which will end the
Teapro program. The limit on string length in Teapro is
100,000,000 bytes. For security, the limit on the string entry
size for the $inp statement is just 1024 bytes.

The number of significant digits in the decimal numbers is set
at fifteen digits, but will sometimes work with sixteen.

It is extremely important that the Teapro interpreter be
absolutely reliable and trustworthy. Please send an e-mail to
dlb@teapro.com if you find any kind of problem with the Teapro
interpreter.
----------------------------------------------------------------
----------------------------------------------------------------
Global variables are defined at the top of the program using
the command vari. Local variables are defined at the top of
subroutines and again the command is vari. Global variables can
be used any where in the program. Local variables can only be
used while the processing is in the subroutine in which they are
defined.

If a variable is a string variable the name must begin with an
"S". If a variable is a decimal variable the name must begin
with a "D". Then, if the variable is a local variable defined in
a subroutine, the first letter is followed by an underline "_"
and then letters and numbers. However, if the variable is a
global variable defined at the top of the program rather than in
a subroutine, then the second character in the name is a "G"
followed by a underline and then letters and numbers. The
minimum length for a variable name is five characters and the
maximum length is sixty-four characters.

An important restriction is that variable names in the same
scope must not overlap. In other words, in a subroutine one
cannot have the variables "d_bytes" and "d_byte" both, since
they overlap. Also, "sg_num" and "sg_number" are not allowed.
Also, "s_num" and "s_num1" are not allowed. By in the same
scope, is meant that both variables are available in the same
subroutine, or both variables are global variables.

Subroutine names must begin with the characters "sub_". Like
variable names they can be upto sixty-four characters long. The
remaining characters must be letters, numbers or underlines. In
subroutine names only are additional underlines permitted beyond
the first one in byte 4.

In other languages there are lists of reserved words which must
be avoided as names for variables and subroutines. Sometimes
there are hundreds of reserved words in other languages. In
Teapro there is no need for for such concern for reserved words
because variables and subroutines cannot be named the same as
commands. Likewise, variables cannot be named the same as
subroutines. Furthermore, local variables and global variables
cannot have the same names.
----------------------------------------------------------------
----------------------------------------------------------------
Assignment operator: in Teapro the assignment operator is the
equal sign ie.

d_decimal1 = d_decimal2 + 1

The above Teapro language program line means to find the value
of the variable d_decimal2 and to add 1 to that value; then, to
store that value in the variable d_decimal1.

s_string1 = "hello" + s_string2 + d_decimal1

The above program line means to take the string "hello" and to
concatenate to it the string in the variable s_string2, and then
to concatenate to that the string value of the decimal number in
the variable d_decimal1. Finally, this resultant string is
stored in the variable s_string1.
----------------------------------------------------------------
Control commands: They control the flow of the program. They
are: dift, dwhi, $ift, $whi, endi, endw, else, subr, ends, endp.
----------------------------------------------------------------
Generic global variables: global variables which a programmer
can set up to pass information to and from subroutines. Usually
names of these are like: sg_pass1, sg_pass2, dg_pass1, dg_pass2.
Of course these are simply global variables like any other
global variables except that the programmer uses them only for
passing information into or out of a subroutine. Of course, you
may any legal global variable names which you care to use.
----------------------------------------------------------------
A numeric literal can be any whole number, or it can be any
decimal number if there is at least one digit, even just a zero,
to the left of the decimal. Numeric literals may have a + or a -
sign in front of them.

d_any = 1234.56789 * - 2 / + 1.7 % + 4 / 0.987654321

Begin with 1234.56789 and multiply by -2, then divide by a
+1.7, then find mod 4 and divide by 0.987654321.
----------------------------------------------------------------
String literal: a string of characters inclosed by either
double quotation marks or by number signs ie. "hello" or
"1234567890" or "!@#_tui672" or #"xyz#.
----------------------------------------------------------------
String append expression: what is to the right of the
assignment operator in a string assignment command ie.

s_string1 = s_string2 + "1234" + d_decimal1

A string append expression evalutes to a string. You can use
string append expressions also in the Teapro commands: $app,
$inp, $out, and $sho.
----------------------------------------------------------------
----------------------------------------------------------------
Here is an example which shows the string assignment command.

s_str1 = s_str2 + "Hello World" + #16.3# + s_str3 + d_dec1
s_str1 = s_str2 + #Hello World# + "16.3" + s_str3 + d_dec1
$set s_str1 = s_str2 + #Hello World# + "16.3" + s_str3 + d_dec1

The three above lines produce the same result. A string literal
may be enclosed in either double quotes, i.e. "hello" or in
number signs, i.e. #hello#.

The first thing to notice is that the string assignment command
does not have a command in front! If you must put a command in
front, you can use $set, but it is preferred to omit it as it is
not needed. The characteristic of the string assignment command
is a variable of type string followed by an equal sign and then
more variables with plus signs between them. The part to the
right of the equal sign is called a string append expression. A
string append expression can also be used with $app, $inp, $out,
and $sho.

The string assignment command merely concatenates string
literals and variables together into one string. Decimal
variables can be concatenated into the string also. Decimal
variables are changed to strings before they are concatenated
into the string.

The other assignment command, the decimal assignment command,
begins with a decimal variable. It is covered in another
chapter.
----------------------------------------------------------------
----------------------------------------------------------------
Here is an example which shows the decimal assignment command.
----------------------------------------------------------------
d_num = - d_dec1 * -412.71 / d_dec2 + d_dec3 % d_dec4 + 86 ^ 2
dset d_num = - d_dec1 * -412.71 / d_dec2 + d_dec3 % d_dec4 + 86 ^ 2

Set d_num to zero, subtract d_dec1, multiply by -412.71, divide
by d_dec2, add d_dec3, find mod d_dec4, add 86, raise to power
2. See command dpow for how exponentiation works.
----------------------------------------------------------------
The answer is the decimal variable to the left of the equal sign.
= means to set the answer to zero.
+ means to add the next number to the answer.
- means to subtract the next number from the answer.
* means to multiply the next number times the answer.
/ means to divide the answer by the next number.
% means to round both to integers and find the modulus or mod.
  The sign of a mod is the same as the sign of the mod of term.
\ means to round both to integers and do an integer divide.
^ means to raise to a power.
@ means to round to a number of decimal places.
? means to truncate to a number of decimal places.
----------------------------------------------------------------
The first thing to notice is that the decimal assignment
command does not have a command in front! If you must have a
command you may use dset, but it is not needed and it is
preferred to be omitted. The defining characteristic of the
decimal assignment command is that a variable of type decimal is
followed by an equal sign and then more decimal variables and
decimal literals with operators between them.

Notice the -412.71 which is a numeric literal which is a
negative number. Numeric literals may have a plus + or a minus -
sign in from of them to make them either positive or negative
numbers. If both the positive and negative signs are not there,
then the number is positive. The 86 does not have a sign and is
positive.

A numeric literal can be any whole number, or it can be any
decimal number if there is at least one digit, even just a zero,
to the left of the decimal. Numeric literals may have a + or a -
sign in front of them.

The decimal assignment command does various mathematical
decimal operations in a strictly left to right order using both
decimal variables and decimal literals. A zero divide or a mod
zero will cause an error which will cause your Teapro program to
end.

Decimal numbers have fifteen significant figures. The placing
of the decimal point in the decimal numbers can be almost
anywhere. Decimals can be any number that one should conceivably
ever need because of the tremendous range of values that they
cover. Sometimes, decimal numbers can be sixteen digits long.

The strict left to right evaluation of the decimal assignment
command has two good reasons to justify it. First, the
programmer will make far fewer errors if she/he is required to
put the variables in the order of evaluation. Secondly, a zero
divide or a mod zero cannot arise unless the variable going into
a decimal assignment command is already zero. That variable can
be tested on a line just prior to the decimal assinment line. A
third reason for the left to right method is that the
interpreter is much simpler.

Notice that mod "%" and integer divide "\" both round the two
numbers before doing the operation. This is a banker's round
which is what is most commonly used in floating point
arithmetic. In floating point arithmetic calculated numbers are
often a tiny tiny bit off from an integer. Doing % or \ without
first rounding the two numbers would give an answer quite
different from what one would expect. Both of these operators
return an integer result. The sign of the mod result is the same
as the sign of the mod of term.

d_number = d_term1 % d_term2
In the above the sign of d_number will be the sign of d_term1.
If one considers how modulus works in algebra, this is true,
also.

If you want to round such that an ending decimal of .5 is
rounded away from zero use the command drou. Also, if you want
to truncate such that the result is an integer closer to zero
than your beginning non-integer decimal number use the command
dtru.

In other languages, the decimal or numerical assignment command
appears to be an algebraic expression for the computer to
evaluate. In these other languages, operator precedence
determines which operations are done first very similarly as
they are done in algebra. In these other languages, however, the
truth of the matter is that when the operators have the same
precedence then a left to right evaluation order is done just as
the language Teapro does all of the time for all operators in
decimal assignment statements.

Teapro greatly simplifies this situation and throws the
decision of order of evaluation to the programmer without the
complications of operator precedence. It is important when doing
floating point math combined with integer math that the
programmer definitely determine the exact order for the
operations to be done in a straight forward manner. The language
Teapro is at this time one of the very few available languages
which offers to the programmer what the programmer needs and
deserves in this respect.

If the first term to the right of the equal sign has no
operator in front of it then a plus sign is understood to be
there.

The string assignment command begins with a variable of type
string and is covered in another chapter.
----------------------------------------------------------------
----------------------------------------------------------------
In the following the Teapro commands are in lowercase for
greater clarity. Most Teapro programmers prefer to use lower
case for the Teapro commands and variables in their programs.
----------------------------------------------------------------
arrb

Blank the string array. The string array holds 2000 strings
with the index ranging from 1 to 2000. Use arrz to zero the
decimal array. Other string array commands are $toi and ito$.
----------------------------------------------------------------
$app s_string1, s_string2

String append. Put s_string1 + s_string2 into s_string1. The
string s_string2 can be a string append expression. Creating a
string longer than 100,000,000 bytes will cause an error.
----------------------------------------------------------------
$bak d_byte, s_lookin, d_start, s_lookfor

Back lookup. Using s_lookin starting at byte d_start backwardly
search or look for s_lookfor. If it is found put the number of
the first byte into d_byte and if it is not found put zero into
d_byte.
----------------------------------------------------------------
$bes s_new, s_old

Blank escape characters in s_old and store the string in s_new.
An escape character is one whose number is less than 32.
----------------------------------------------------------------
$ch$ s_new, s_char, d_long

String character to string. Make s_new of length d_long of the
first character of s_char. Creating a string longer than
100,000,000 bytes will cause an error.
----------------------------------------------------------------
$chd d_char, s_char

String character to decimal. Find the character number of the
first character of s_char and put that number into d_char.
----------------------------------------------------------------
$clo s_new, s_old

Make case lower. Make s_old lower case and store in s_new.
----------------------------------------------------------------
$cnt d_count, s_string, s_find

Put count of occurrences of s_find in s_string into d_count.
Occurrences cannot overlap.
----------------------------------------------------------------
$cod s_new, s_old

Code s_old into s_new. Code and decode are the same operation.
This is an entirely different type of encryption than done by
$toe.
----------------------------------------------------------------
$cup s_new, s_old

Case make upper. Make s_old uppercase and store in s_new.
----------------------------------------------------------------
$cut s_partstring, s_wholestring, d_byte, d_long

Cut string from string. Put into s_partstring a portion of
s_wholestring starting at byte d_byte for length d_long.
----------------------------------------------------------------
$dat s_date

Put the date as a string into s_date. The date string contains
the date and time in two formats:
"22-MAR-2002 21:28:16 20020322212816".
----------------------------------------------------------------
$del s_string, d_beg, d_long

String delete. In string s_string starting at d_beg delete the
bytes for a length of d_long.
----------------------------------------------------------------
$dot d_dot, s_string1, s_string2, d_which

Find certain string occurrence and put location in d_dot. Find
occurrence d_which of s_string2 in s_string1 and put the number
of the first byte of that occurrence into d_dot. Occurrences of
s_string2 cannot overlap a previous occurrence. If the wanted
occurrence of the wanted string is not found then put zero into
d_dot.
----------------------------------------------------------------
$hsh d_hash, s_string

String hash. Create a hash number d_hash that is fairly unique
for the string s_string. The hash decimal number d_hash can be
15 digits long. The first 9 are merely a total of the char
numbers of the bytes in the file. The last six represent a total
of the char numbers times the positions in records which are 701
bytes long. 701 is prime. Char numbers run from 1 to 256 for
these calculations.
----------------------------------------------------------------
$ift s_string1 = s_string2
$ift s_string1 = s_string2: $out "hello world"

If s_string1 equals s_string2 then perform all of the command
lines down to the matching else or endi command. If they do not
equal then jump down to the appropriate else or endi command.

If the command line beginning with $ift ends with a colon and
another command line, then only that other command line is
conditioned by the $ift. That other command line must not be a
control command.

You may use any of the following compare options with $ift:
=  is equal to
<  is less than
<= is less than or equal to
<> is not equal to
>  is greater than
>= is greater than or equal to
----------------------------------------------------------------
$inp s_input, s_output

Output s_output to screen and input from the keyboard s_input.
s_output can be a string expression. For security, the maximum
length of s_input for $inp is 1024 bytes for security.
----------------------------------------------------------------
$ins s_wholestring, d_byte, s_partstring

Insert string into string. Insert into s_wholestring starting
at byte d_byte the string s_partstring. If d_byte is the length
of s_wholestring plus one then s_partstring is appended at the
end. Creating a string longer than 100,000,000 bytes will cause
an error.
----------------------------------------------------------------
$isc d_yesno, s_string, s_char

String is a string of characters s_char? If s_string is a
string of the first character of s_char then put 1 in d_yesno
else 2.
----------------------------------------------------------------
$isd d_yesno, s_string

String is decimal. If string s_string is a decimal number then
put 1 in d_yesno otherwise put 2 in d_yesno.
----------------------------------------------------------------
$isp d_yesno, s_string, s_pattern

String s_string is a type pattern match with string s_pattern.
Compare s_string and s_pattern to see if the pattern of types
match. If yes then put a 1 in d_yesno. If not put a 2 in
d_yesno. Types of characters are: escapes, blanks, punctuation,
numbers, uppers, lowers, and char greater than #126. The two
strings must also be the same length.
----------------------------------------------------------------
$ist d_yesno, s_string, s_type

String s_string is made up of characters of the same type as
the first character of s_type. If yes then put 1 in d_yesno. If
no then put 2 in d_yesno. Types of characters are: escapes,
blanks, punctuation, numbers, uppers, lowers, and char greater
than #126.
----------------------------------------------------------------
$len d_long, s_string

String length. Put length of string s_string into d_long.
----------------------------------------------------------------
$lok d_byte, s_wholestring, d_start, s_partstring

Look for s_partstring in s_wholestring starting at byte
d_start. If it is found put the beginning byte number in d_byte.
If it is not found put zero in d_byte.
----------------------------------------------------------------
$off s_result, s_string, d_long

Cut off end of string s_string for d_long bytes and store it in
s_result.
----------------------------------------------------------------
$out s_output

String out. Output to the screen s_output. s_output can be a
string expression made up of string variables and literals as
well as decimal variables. $out does a carriage return and line
feed at the end to move the line up.
----------------------------------------------------------------
$par s_toextract, s_csv, s_char, d_which

Parse a string. Extract string s_toextract from the character
separated value string s_csv indicated by number d_which.
Strings in s_csv are separated by occurrences of s_char. The
length of s_char must be 1. If d_which=1 then return the string
ending with the first occurrence of s_char. If d_which=6 return
the string ending with the sixth occurrence of s_char.
----------------------------------------------------------------
$pkd d_yesno, d_decimal, s_string

String in packed format to decimal. Convert the packed format
number in s_string into a whole number decimal d_decimal. Packed
decimal format is also called BCD or binary coded decimal. If
s_string can be converted to a decimal number put 1 in d_yesno
otherwise put 2 in d_yesno.
----------------------------------------------------------------
$rep s_wholestring, d_byte, s_partstring

Replace part of a string with another string. In s_wholestring
starting at byte d_byte replace the bytes with s_partstring. The
length of s_wholestring is never changed by this command.
----------------------------------------------------------------
$set s_string1 = s_string2 + " hello there " + s_string3 + # WOW #

String set. This is the string assignment command in Teapro. It
is actually preferred to omit the $set command at the beginning.
Notice that string literals may be enclosed in double quotes or
pound signs.
----------------------------------------------------------------
$sho s_output

String show. Output to the screen s_output. s_output can be a
string expression made up of string variables and literals as
well as decimal variables. $sho does not do a carriage return
and a newline afterwards.
----------------------------------------------------------------
$sor s_new, s_old, d_long

Sort string. Sort the string s_old into string s_new by
sections each d_long in length.
----------------------------------------------------------------
$swp s_string, s_old, s_new

String swap. In s_string replace each occurrence of s_old with
s_new.
----------------------------------------------------------------
$sys s_info, d_which

System or program information to s_info depending on d_which.
1 = path and filename of this running Teapro Interpreter
2 = current subroutine name of Teapro program
3 = version of current Teapro program
4 = name of current loaded Teapro program
----------------------------------------------------------------
$tlo s_new, s_old

String trim low. Trim string s_new and make lower case. Then
put it into s_old.
----------------------------------------------------------------
$tod d_decimal, s_string

String to decimal. Convert the string in s_string to a decimal
number and store it in decimal variable d_decimal. If s_string
cannot be converted to a decimal number an error occurs.
Usually, one should use $isd to test s_string first to see if it
can be converted to a decimal.
----------------------------------------------------------------
$toe s_new, s_old, s_key, d_which

String to encoded. Code s_old into s_new using key s_key. If
d_which=1 encode. If d_which=2 then decode. s_key must be
letters and numbers, and is not case sensitive. This encryption
is about 29 bit in strength which makes it pretty weak. There
are only about 700,000,000 possible keys. This is an entirely
different type of encryption from $cod. This encryption is
called OldToe.
----------------------------------------------------------------
$toi d_index, s_string

String to index. Put the string s_string in the array of
strings at index d_index. The array of strings has 2000 strings
with the index ranging from 1 to 2000. If the index d_index is
outside of this range an error will occur which will cause the
running Teapro program to end. s_string cannot be a string
append expression.
----------------------------------------------------------------
$trb s_new, s_old

Trim the blanks and escape characters from both ends of s_old
and put the string in s_new.
----------------------------------------------------------------
$trl s_new, s_old

Trim the blanks and escape characters from the left end of
s_old and put the string in s_new.
----------------------------------------------------------------
$trr s_new, s_old

Trim the blanks and escape characters from the right end of
s_old and put the string in s_new.
----------------------------------------------------------------
$tup s_new, s_old

Trim string s_old and make it upper case. Then put it in s_new.
----------------------------------------------------------------
$whi s_string1 > s_string2

String while command beginning a while block which ends with
endw. The comparison can be >,=,<,>=,<=, or <>. If the
comparison is true the while loop continues. If the comparison
is not true the block is skipped over and the line under the
endw is processesed next.
----------------------------------------------------------------
ito$ s_string, d_index

Index to string. Get the string that is in the array of strings
at index d_index and put that string in s_string. The array of
strings has 2000 strings with the index ranging from 1 to 2000.
If the index d_index is outside of this range an error will
occur which will end the running Teapro program.
----------------------------------------------------------------
In the following the Teapro commands are in lowercase for
greater clarity. Most Teapro programmers prefer to use lower
case for the Teapro commands in their programs.
----------------------------------------------------------------
addi d_index, d_decimal

Add to decimal array at index. Add decimal d_decimal to decimal
array value at d_index and put total back in decimal array at
d_index. The decimal array index d_index cannot be less than 1
or greater than 96000. Other decimal array commands are arrz,
dtoi, itod.
----------------------------------------------------------------
arrz

Zero the decimal array. The decimal array holds 96000 decimal
values with the index value ranging from 1 to 96000. Use arrb to
blank the string array. Other decimal array commands are addi,
dtoi, itod.
----------------------------------------------------------------
dabs d_result, d_number

Absolute value. Put the absolute value of d_number into
d_result.
----------------------------------------------------------------
darc d_radians, d_sin

Get the arcsine of a number. Put the arcsine of sine d_sin into
d_radians. d_sin is made to be 1 if greater than 1 and is made
to be -1 if less than -1.
----------------------------------------------------------------
dbad d_number1 >= d_number2

Bad decimal variable test. If the condition is true, then we
have an error and the running Teapro program will end. dbad is
quick and is to be used only for testing for near disaster
situations. Any of the standard tests can be used ie. <, >, =,
<=, >=, <>.
----------------------------------------------------------------
dbug

The teapro command dbug gives immediate access to all of the
variables and various numbers that control the running of the
current running teapro program. It can be used as the result of
a dift so that it only comes up under certain circumstances. By
rights it should be EBUG instead since it is more of a control
or information giving command. The opportunity to name a command
dbug was just too much to resist.
----------------------------------------------------------------
dch$ s_string, d_char, d_long

Decimal character to string. Make a string s_string of the
character corresponding to d_char of length d_long.
----------------------------------------------------------------
dcut d_number, s_string, d_begIN, d_long
Cut a number from a string. Cut d_number from s_string
beginning at byte d_begIN for length d_long or stop when a
non-number occurs. This is very similar to $cut.
----------------------------------------------------------------
ddec d_decimal

Decrement d_decimal by 1.
----------------------------------------------------------------
dduo d_factor, d_1quadpart, d_1quadmult

Test a number for primeness and also that number plus two with
one command. dduo has the exact same format as dfak. In other
words, is the number the first of a prime duo? Following is the
info for dfak. If d_factor ends up with a 1 in it then we have a
prime duo or twin.

Find the lowest factor of a test number such that d_1quadpart
is the part of the test number less than 1E15 and d_1quadmult is
the number of quadrillions, ie. 1E15, of the test number. For
example, suppose the test number is 123,456,789,012,345,678,901.
The part below 1E15 is 789,012,345,678,901 and this would be put
into d_1quadpart as it is the PART below 1E15. Into d_1quadmult
we would need to put 123,456 as it is the number of
quadrillions, ie 1E15. This test number has a d_factor of 11.
Another test number is 108,000,000,000,000,001. Into d_1quadpart
we put 1. Into d_1quadmult we put 108. dfak gives 1 for d_factor
meaning that this test number is prime. dfak will work for sure
only if d_1quadmult is 1,604,388 or less. The entire number must
be 1,604,388,996,928,588,480,512 or less.

This is the Teaquad method of testing large numbers for
primeness.
----------------------------------------------------------------
ded$ s_string, d_decimal, d_long, d_places

Decimal edit to string. Change d_decimal into string s_string,
and give it a length of at least d_long, right justified. Show
the number of decimal positions in d_places. Separate 1000's
with commas. The command dto$ is the same but does not put in
commas. If d_long and d_places are both zero then the number
will be its natural length with no leading zeros and no trailing
zeros to the right of the decimal.
----------------------------------------------------------------
dfac d_factor, d_number

Find the lowest integer factor of d_number greater than one and
put it in d_factor. If there are none greater than one put one
in d_factor. If d_factor ends up with one then d_number is
prime. dfac only works for numbers less than 2^53 or
9,007,199,254,740,992. For numbers greater than that upto 4E20
use dfak.
----------------------------------------------------------------
dfak d_factor, d_1quadpart, d_1quadmult

Find the lowest factor of a test number such that d_1quadpart
is the part of the test number less than 1E15 and d_1quadmult is
the number of quadrillions, ie. 1E15, of the test number. For
example, suppose the test number is 123,456,789,012,345,678,901.
The part below 1E15 is 789,012,345,678,901 and this would be put
into d_1quadpart as it is the PART below 1E15. Into d_1quadmult
we would need to put 123,456 as it is the number of
quadrillions, ie 1E15. This test number has a d_factor of 11.
Another test number is 108,000,000,000,000,001. Into d_1quadpart
we put 1. Into d_1quadmult we put 108. dfak gives 1 for d_factor
meaning that this test number is prime. dfak will work for sure
only if d_1quadmult is 400,000 or less.

This is the Teaquad method of testing large numbers for
primeness.
----------------------------------------------------------------
dift d_decimal1 = d_decimal2
dift d_decimal1 = d_decimal2: $out "hello there"

If d_decimal1 equals d_decimal2 then perform all of the command
lines down to the matching else or endi command. If they do not
equal then jump down to the appropriate else or endi command.

If the dift command line is followed with a colon and another
command line, then the dift command line conditions only that
other command line. That other command line may not be a control
command.

You may use any of the following compare options with dift: =,
>, >=, <, <= or <>.
----------------------------------------------------------------
dinc d_decimal

Decimal increment. Increment d_decimal by one.
----------------------------------------------------------------
dlog d_log, d_number

Logarithm of base 10. Put the common or base 10 logarithm of
d_number into d_log. d_number is made positive if negative and
d_log is zero if d_number is zero.
----------------------------------------------------------------
dpk$ s_string, d_decimal, d_long

Decimal number to a packed format string. Round d_decimal to a
whole number and then change it into a string of packed format
of length d_long. Packed decimal format is also called binary
coded decimal or BCD.
----------------------------------------------------------------
dpow d_result, d_number, d_power

Raise d_number to power d_power and put into d_result. d_number
must be greater than zero. If d_number is negative and d_power
is not an integer then make d_number positive first.
----------------------------------------------------------------
dran d_random

Put a decimal random number between 0 and 1 in d_random.
----------------------------------------------------------------
drou d_new, d_old

Round decimal number to integer. Round decimal number d_old and
put the result in d_new. A decimal amount of 0.5 is rounded away
from zero.
----------------------------------------------------------------
dsec d_seconds

Put seconds in d_seconds. This is used to time various events.
The difference between two calls of this command will be the
time in seconds that has passed.
----------------------------------------------------------------
dsin d_sin, d_radians

Sine of a number. Put the sine of number d_radians which is an
angle in radians into d_sin. If d_radians > 2*PI then d_radians
is made to be 2*PI. If d_radians < -2*PI then d_radians is made
to be -2*PI.
----------------------------------------------------------------
d_result = -d_num1 * d_num2 - d_num3 / d_num3 % d_num4 \ d_num5
dset d_result = -d_num1 * d_num2 - d_num3 / d_num3 % d_num4 \ d_num5

Decimal set. The right side is evaluated strictly left to
right. It is preferred here to omit the dset command altogether.
The operators are:

+ is add
- is subtract
* is multiply
/ is divide
% is round both to an integer and find the mod.
  The sign of a mod result is the same as the mod of term.
\ round both to an integer and do an integer divide.
^ means to raise to a power.
@ means to round to a number of decimal places.
? means to truncate to a number of decimal places.

Literal numbers can be used as the decimal variables are used
if the numbers are -99999 to +99999 with no decimal places.
----------------------------------------------------------------
dsys d_amount, d_number

Decimal system info.
d_number=1 means put total string length in d_amount.
d_number=2 means put lines of Teapro done in d_amount.
d_amount=3 means put total line length of program in d_amount.
----------------------------------------------------------------
dto$ s_string, d_decimal, d_long, d_places

Decimal to string. Change d_decimal into string s_string, and
give it a length of at least d_long, right justified. Show the
number of decimal positions in d_places. Do not put in commas as
in ded$. If d_long and d_places are both zero then the number
will be its natural length with no leading zeros and no trailing
zeros to the right of the decimal.
----------------------------------------------------------------
dtof s_string, d_decimal, d_long

Decimal to field. Change decimal d_decimal into a string
s_string of length d_long such that s_string begins with + or -,
is right justified and zero filled. This format is needed many
times for a field in a record. The decimal d_decimal is rounded
to a whole number.
----------------------------------------------------------------
dtoi d_index, d_decimal

Decimal to index. Put the decimal d_decimal into the array of
decimals at index d_index. The array of decimals has 96000
decimals with the index ranging from 1 to 96000. If the index
d_index is outside of this range an error will occur and the
running Teapro program will end. Other decimal array commands
are arrz, itod, addi.
----------------------------------------------------------------
dtru d_new, d_old

Truncate decimal number. Truncate decimal number d_old and put
the result in d_new. If d_old is not an integer, d_new will be
closer to zero than d_old.
----------------------------------------------------------------
dwhi d_decimal1 < d_decimal2

Decimal while. While d_decimal1 is less than d_decimal2 perform
the lines of commands down to the matching endw; otherwise, jump
to line right after the endw. The following compares can be use:
=, >, >=, <, <= and <>.
----------------------------------------------------------------
itod d_decimal, d_index

Index to decimal. Get the decimal that is in the array of
decimals at index d_index and put that decimal in d_decimal. The
array of decimals has 96000 decimals with the index ranging from
1 to 96000. If the index d_index is outside of this range an
error will occur and the running Teapro program will end.
----------------------------------------------------------------
----------------------------------------------------------------
addi d_index, d_decimal

Add to decimal array at index. Add decimal d_decimal to decimal
array value at d_index and put total back in decimal array at
d_index. The decimal array index d_index cannot be less than 1
or greater than 96000. Other decimal array commands are arrz,
dtoi, itod.
----------------------------------------------------------------
arrb

Blank the string array. The string array holds 2000 strings
with the index ranging from 1 to 2000. Use arrz to zero the
decimal array.
----------------------------------------------------------------
arrz

Zero the decimal array. The decimal array holds 96000 decimal
values with the index value ranging from 1 to 96000. Use arrb to
blank the string array.
----------------------------------------------------------------
dtoi d_index, d_decimal

Decimal to index. Put the decimal d_decimal into the array of
decimals at index d_index. The array of decimals has 96000
decimals with the index ranging from 1 to 96000. If the index
d_index is outside of this range an error will occur and the
running Teapro program will end. Other decimal array commands
are addi, itod, arrz.
----------------------------------------------------------------
itod d_decimal, d_index

Index to decimal. Get the decimal that is in the array of
decimals at index d_index and put that decimal in d_decimal. The
array of decimals has 96000 decimals with the index ranging from
1 to 96000. If the index d_index is outside of this range an
error will occur and the running Teapro program will end.
----------------------------------------------------------------
ito$ s_string, d_index

Index to string. Get the string that is in the array of strings
at index d_index and put that string in s_string. The array of
strings has 2000 strings with the index ranging from 1 to 2000.
If the index d_index is outside of this range an error will
occur and the running Teapro program will end.
----------------------------------------------------------------
$toi d_index, s_string

String to index. Put the string s_string in the array of
strings at index d_index. The array of strings has 2000 strings
with the index ranging from 1 to 2000. If the index d_index is
outside of this range an error will occur and the running Teapro
program will end. s_string cannot be a string append expression.
----------------------------------------------------------------
In the following, the Teapro commands are in lowercase for
greater clarity. Most Teapro programmers prefer to use lower
case for the Teapro commands in their programs.
----------------------------------------------------------------
$ift s_string1 = s_string2
$ift s_string1 = s_string2: $out "hello world"

If s_string1 equals s_string2 then perform all of the command
lines down to the matching else or endi command. If they do not
equal then jump down to the appropriate else or endi command. If
the command line beginning with $ift ends with a colon and
another command line, then only that other command line is
conditioned by the $ift. That other command line must not be a
control command. You may use any of the following compare
options with $ift: =, >, >=, <, <= or <>.
----------------------------------------------------------------
dift d_decimal1 = d_decimal2
dift d_decimal1 = d_decimal2: $out "hello world"

If d_decimal1 equals d_decimal2 then perform all of the command
lines down to the matching else or endi command. If they do not
equal then jump down to the appropriate else or endi command. If
the dift command line is followed with a colon and another
command line, then the dift command line conditions only that
other command line. That other command line may not be a control
command. You may use any of the following compare options with
dift: =, >, >=, <, <= or <>.
----------------------------------------------------------------
dwhi d_decimal1 = d_decimal2

While d_decimal1 equals d_decimal2 perform the lines of
commands down to the matching endw. The following compares can
be use: =, >, >=, <, <= and <>.
----------------------------------------------------------------
else

The command else is the middle part of the $ift or dift, else,
endi block. Program lines between the $ift or dift and the else
are performed if the condition is true. If the condition is not
true then the program lines between else and the matching endi
are performed instead. An $ift or dift and endi block does not
have to have an else part.
----------------------------------------------------------------
endi

End of if block. The command endi is the end command of the
$ift or dift, else, endi block. Every one of these blocks must
have an endi command. Without the else command, this blocks
allows performance of the commands between the top part and the
bottom endi part only if the condition is true. See the else
command for how it works.
----------------------------------------------------------------
endp

End program. The endp command ends the program.
----------------------------------------------------------------
ends

The command ends is the ending line to subroutines.
----------------------------------------------------------------
endw

The command endw is at the ending line of the while loop block
of lines, which began with dwhi or $whi. While the condition of
the dwhi or $whi command is true the loop will continue looping.
----------------------------------------------------------------
gtag tag_top1

This is the tag that the command "goto tag_top1" goes to. Both
have to be in the same subroutine. gtag names begin with "tag_"
and are local to the subroutine they are in.
----------------------------------------------------------------
goto tag_top1

Go to the line which has "gtag tag_top1" on it. Both have to be
in the same subroutine. Each gtag line can have many
corresponding goto lines.
----------------------------------------------------------------
sub_some_subroutine

Exit to subroutine sub_some_subroutine. The name of the
subroutine must begin with "sub_" and be no more than sixty-four
characters in total length. Exiting to a subroutine is what is
meant by "calling" it.
----------------------------------------------------------------
subr sub_some_subroutine

Subroutine. The command subr followed by a subroutine name
forms the top line in a subroutine block. The bottom line in a
subroutine block is the ends command. A subroutine must be
called for the commands in it to be performed. Call a subroutine
using the name of it in calculations.
----------------------------------------------------------------
vari d_decimal1, s_string2, s_string3, s_string4, d_decimal5

Variable declaration. Use the vari command to declare variables
which can be in any order or of any of the two types.
----------------------------------------------------------------
----------------------------------------------------------------
fadd d_long, s_file, s_record

File add. Add a record s_record to the end of file s_file and
put a line feed character on the end. Put the total length added
to the file in d_long. The maximum length of the data that can
be written is 4096. If the command succeeds, the length written,
d_long, to the file will be one more than the length of
s_record. Use the command fapp to add a record to the file with
a carriage return and a line feed added to the end.
----------------------------------------------------------------
fapp d_long, s_file, s_record

File append. Append a record s_record to the end of file s_file
and put a carriage return and a line feed character on the end.
Put the total length added to the file in d_long. The maximum
length of the data that can be written is 4096. If the command
succeeds, the length written, d_long, to the file will be two
more than the length of s_record. Use the command fadd to add a
record to the file with just a line feed on the end.
----------------------------------------------------------------
fdel d_yes, s_file

File delete. Delete the file named in s_file. If the file is
deleted put 1 in d_yes else put 2 in d_yes.
----------------------------------------------------------------
finp s_record, s_file

File input. The file name is in s_file. Input that entire file
into the string s_record. If the length of the file is greater
than 100,000,000 bytes an error will occur.
----------------------------------------------------------------
flen d_long, s_file

File length. Find the length in bytes of the file named in
s_file and put it into d_long. If the file cannot be accessed or
cannot be found put -1 in d_long.
----------------------------------------------------------------
fout d_byteS, s_file, s_record

File output. The string to be outputted is in s_record. Output
the entire string into the file whose name is in s_file. The
total number of bytes written goes in d_byteS. The entire file
will consist of what was in s_record.
----------------------------------------------------------------
frea s_record, s_file, d_byte, d_long

File read. Read from the file named in s_file starting at byte
d_byte for length d_long and put that record into s_record. In
Teapro the first byte of a file is byte 1. If the file read
fails for some reason the resulting string will have less length
than hoped for. The maximum length of the data read can be 4096
bytes.
----------------------------------------------------------------
fren d_yes, s_file2, s_file1

File rename. Rename the file named in s_file1 to the name in
s_file2. If the file is renamed put 1 in d_yes else put 2 in
d_yes.
----------------------------------------------------------------
fsip s_record, s_file, d_filebyte

File sip. Sip or read a variable length record s_record
starting at d_byte and ending in a line feed from file s_file
and remove the line feed. Put the beginning of the next record
into d_filebyte. If no record was read put zero in d_filebyte.
Zero length records are possible. You must put 1 in d_filebyte
for the first read. The maximum length of the data read is 4096
bytes. Variable length records in files end with a line feed
which means they end with character = 10. The command fsip
blanks escape characters in s_record.
----------------------------------------------------------------
fwri d_length, s_file, d_byte, s_record

File write. Write to the file named in s_file starting at byte
d_byte the string in s_record. The number of bytes written goes
in d_length. In Teapro the first byte of a file is byte 1. The
maximum length of the data written can be 4096 bytes.
----------------------------------------------------------------
Here is a short Teapro program to show how one can read through
a file using the command frea and to output the records to the
screen.

If we were writing a program to be used for reading through
files we would add to it lines to take care of various problems
which might arise.

Comment lines explain the program line just under them. The
commands and variables are in lowercase and the comments are
mostly in lower. This is just for easy following of the program.
A programmer can use either or both cases for either or both.
----------------------------------------------------------------
'there are no global variables in this program if there were
'some they would be defined here with the vari command
'call the subroutine sub_readfile
sub_readfile

'the endp command ends the program
endp

'the following code is for the subroutine sub_readfile
subr sub_readfile

   'the next two lines define the variables local to this subroutine
   vari d_record, s_record, s_filename, d_byte, s_inp
   vari d_reclength, d_long, d_loop

   'prompt user to enter the filename into the variable s_filename
   $inp s_filename, "enter the file name"

   'prompt the use to enter the record length into s_inp
   $inp s_inp, "enter the record length"

   'change s_inp to a decimal variable d_reclength
   $tod d_reclength, s_inp

   'initialize d_record to one for the record number
   d_record = 1

   'set decimal variable d_loop to one
   d_loop = 1

   'while d_loop is one keep looping
   dwhi d_loop = 1

       'find the byte number to read from to get record d_record
       d_byte = d_record - 1 * d_reclength + 1

       'read file s_filename beginning at byte d_byte for length
       'd_reclength and put the record into s_record
       frea s_record, s_filename, d_byte, d_reclength

       'find length of s_record and put into d_long
       $len d_long, s_record

       'if d_long = d_reclength the do the following lines
       dift d_long = d_reclength

           'output s_record to the screen
           $out s_record

           'increment d_record by one
           dinc d_record

           'else is the control command to do else in dift/$ift
       else

           'use dinc to increment d_loop by one
           dinc d_loop

       'endi is the command to end a dift or $ift control command
       endi

   'endw is the control command to end the loop begun with dwhi
   endw

   'prompt user to hit return
   $inp s_inp, "return"

'ends is the control command for ending a subroutine
ends sub_readfile
----------------------------------------------------------------
----------------------------------------------------------------
This is similar to the chapter on reading through a file using
the fsip command. fsip is better suited for files with variable
length records than is the command frea.
----------------------------------------------------------------
'call the subroutine sub_readfile
sub_readfile

'the endp command ends the program
endp

'the following code is for the subroutine sub_readfile
subr sub_readfile

   'the next two lines define the variables local to this subroutine
   vari s_record, s_filename, d_filebyte, s_inp
   vari d_long, d_loop

   'prompt user to enter the filename into the variable s_filename
   $inp s_filename, "enter the file name"

   'set the variable d_filebyte to 1 to begin at the beginning
   d_filebyte = 1

   'set decimal variable d_loop to one
   d_loop = 1

   'while d_loop is one keep looping
   dwhi d_loop = 1

       'read a record from s_filename beginning at byte d_filebyte
       fsip s_record, s_filename, d_filebyte

       'we have a good record if d_filebyte is not zero
       dift d_filebyte > 0

           'output s_record to the screen
           $out s_record

           'else is the control command to do else in dift/$ift
       else

           'use dinc to increment d_loop by one to end the loop
           dinc d_loop

       'end the dift command block
       endi

   'endw is the control command to end the loop begun with dwhi
   endw

   'prompt user to hit return
   $inp s_inp, "return"

'ends is the control command for ending a subroutine
ends sub_readfile
----------------------------------------------------------------
----------------------------------------------------------------
In Teapro, numbers are called decimal numbers because they can
have digits to the right of the decimal point. They are actually
binary floating point numbers which have fifteen digit accuracy
as decimal numbers.

The accuracy is actually a little better than fifteen digits.
For example, suppose you are working with positive numbers that
have no digits to the right of the decimal. Such numbers are
usually called integers if they are all there over the
applicable range and if they can be converted to strings. The
applicable range of such Teapro decimal numbers is from 1 to
9.007E15. What this means is 9.007 times 10 raised to the 15th
power. This is commonly called scientific notation. Written out
exactly this number is: 9,007,199,254,740,991. It is actually
two raised to the fifty-third power minus one.

If you begin adding one to say 9.00715E, you will shortly get a
situation such that adding one does not change the number. When
this happens you have slightly exceeded the maximum range of
accuracy of the Teapro decimal numbers. That maximum is the two
raised to the fifty-third power minus one. All of this applies
similarly to negative Teapro decimal numbers.

For business programming which does lots of addition with two
decimal money amounts, the Teapro decimal numbers should be used
as whole numbers representing the amount of money in cents.
Since Teapro does all of its arithmetic using floating point
arithmetic, the only way to guarantee the accuracy of the cents
is to do all of the arithmetic using cents instead of dollars.
Binary floating point arithmetic works best with whole integer
numbers when exact accuracy is required when adding quantities
of numbers together.

The decimal number 0.10 representing ten cents is not exactly
0.10 using floating point arithmetic. This is why the addition
of several hundreds of values which have two decimal places will
sometimes be off by 0.01 or possibly more. If you divide 1 by 10
what you will get with Teapro is the number:
0.10000000000000000555. This is using teapro.exe compiled with
Borland's C++ Builder 1.0 for Windows.

This is the reason that the two packed commands, $pkd and dpk$,
use whole numbers only. Packed decimal numbers are also called
binary coded decimal or BCD.

if you need to round a number to an integer, you can do this by
doing the command drou which rounds away from zero as is usually
used in the business world.

If you want to truncate your non-integer decimal number to an
integer which is less than it is use the command dtru.

If you are doing money and are using cents as your unit in
order to use whole numbers, you can output the number in dollars
by doing the following.
----------------------------------------------------------------
d_dollars = d_cents / 100
ded$ s_dollars, d_dollars, 10, 2
$out "The amount in dollars = " + s_dollars
----------------------------------------------------------------
----------------------------------------------------------------
Here is a sample program written in Teapro. Following the
program is a line by line explanation of it. Generally, a
program should have lots of comment lines. In the following
program these have been omitted to make reading the program
easier. This is a rather trivial program, but it is just a
sample program for show. Blank lines are added to make the
program more readable. When you program in Teapro use blank
lines and comment lines as much as you think best, since they do
not hurt the performance of the program. Also, notice the
indentation. Indentation does not hurt performance at all and
makes the control blocks much easier to follow.
----------------------------------------------------------------
vari dg_pass1

sub_main
endp

subr sub_main
   vari d_count

   d_count = 0
   dwhi d_count < 5
       dg_pass1 = d_count
       sub_decimal_out
       d_count = dg_pass1
   endw
ends sub_main

subr sub_decimal_out
vari d_decimal, s_string

   d_decimal = dg_pass1 + 1
   dto$ s_string, d_decimal, 10, 0
   $out s_string
   dg_pass1 = d_decimal
ends sub_decimal_out
----------------------------------------------------------------
The following is a line by line explanation of the above sample
program.
----------------------------------------------------------------
vari dg_pass1

The above line defines a global decimal variable to be used to
pass a decimal from one subroutine to the other. It is also used
to pass a decimal from the second subroutine back to the
subroutine calling it.
----------------------------------------------------------------
sub_main

This line calls the subroutine sub_main.
----------------------------------------------------------------
endp

This line marks the end of a Teapro program. The Teapro
interpreter stops at this line.
----------------------------------------------------------------
subr sub_main

This line is the first line of the subroutine sub_main.
----------------------------------------------------------------
vari d_count

This line creates a local decimal variable d_count which is
only visible in the subroutine sub_main. It will be used as a
counter to count the number of times the subroutine
sub_decimal_out is called.
----------------------------------------------------------------
d_count = 0

This line assigns the value zero to the local decimal variable
d_count.
----------------------------------------------------------------
dwhi d_count < 5

This is the first line of a while loop which ends with the line
endw a few lines on down. The lines within this loop are
performed while the decimal variable d_count is less than five.
At that point the control of the program falls out of the loop.
----------------------------------------------------------------
dg_pass1 = d_count

This line puts the local decimal variable d_count into the
global decimal variable dg_pass1 to send the value of d_count to
the subroutine sub_decimal_out which is then called on the next
line.
----------------------------------------------------------------
sub_decimal_out

This line calls the subroutine sub_decimal_out.
----------------------------------------------------------------
d_count = dg_pass1

This line assigns the decimal value sent back by the subroutine
to the local decimal variable d_count.
----------------------------------------------------------------
endw

This line marks the bottom of the while loop begun earlier.
----------------------------------------------------------------
ends sub_main

This line is the end of the sub_main subroutine. The name of
the subroutine is not required but makes the program more
readable.
----------------------------------------------------------------
subr sub_decimal_out

The above line is the first line of a subroutine named
sub_decimal_out. The name of a subroutine must begin with "sub_"
and must be no more than 20 characters. Other underline
characters may be used in names of subroutines but not in
variable names.
----------------------------------------------------------------
vari d_decimal, s_string

The above line defines two local variables to this subroutine.
One is a decimal named: d_decimal. The other is a string named
s_string. Variable names must be no more than 20 characters and
must have one underline character but no more. Local variable
names begin with d_ or s_ depending upon which type of variable
they are. Global variables which are defined at the top of the
program and are not in a subroutine must begin with dg_ or sg_.
----------------------------------------------------------------
d_decimal = dg_pass1 + 1

The above is a decimal assignment command. Take the part to the
right of the equal sign and evaluate is strictly left to right
using the operators to determine whether to add, subtract,
multiply, divide, mod or do integer division. In this case take
the global decimal variable dg_pass1, add 1 to it and put that
into the local decimal variable d_decimal. The global decimal
variable dg_pass1 is bringing a decimal value into this
subroutine as though the calling of the subroutine had a
parameter.
----------------------------------------------------------------
dto$ s_string, d_decimal, 10, 0

The above command is called decimal to string. It changes the
local decimal variable d_decimal into a string of minimum length
10 and puts the string into local string variable s_string. The
decimal in the string of minimum length 10 is right justified.
The fourth parameter of 0 means to truncate to 0 decimal
positions.
----------------------------------------------------------------
$out s_string

The above command is the string out command. It outputs the
local string variable s_string to the output window bottom line
of the Teapro interpreter.
----------------------------------------------------------------
dg_pass1 = d_decimal

The above command is a decimal assignment command. It assigns
the decimal in d_decimal to the global variable dg_pass1 in
order to send it back to the subroutine that called this
subroutine. The decimal variable d_decimal is a local variable
which can only be used in this subroutine. In other places this
variable cannot even be seen to exist at all. In order to get
the value of d_decimal out of this subroutine it is necessary to
assign that value to a global variable to get it back to the
subroutine which called this subroutine.
----------------------------------------------------------------
ends sub_decimal_out

The above is the end subroutine command. It marks the end of
the subroutine sub_decimal_out. It is not necessary to have the
name of the subroutine follow the command but it helps to make
the listing more readable.
----------------------------------------------------------------
The output of this sample program would look like the
following.
----------------------------------------------------------------
        1
        2
        3
        4
        5
----------------------------------------------------------------
----------------------------------------------------------------
The following are the specific constructs which make up the
OpenTea Programming Language Technology. The OpenTea Technology
is what makes the interpreted language Teapro so simple, so
useful and so much different from other modern computer
programming languages. All of this information is discussed
earlier but is here summarized.
----------------------------------------------------------------
1. File processing commands have the file name as a parameter
in a string variable so that those commands can both open and
then close the file. No file is ever left open from one command
to another.
----------------------------------------------------------------
2. Order of operation in assignment commands is done strictly
left to right for greatly improved simplicity. The part to the
right of the equal sign is not an algebraic expression as in
other languages which has to be solved algebraically. Decimal
expressions are not allowed in other commands in Teapro. A
number to divide by cannot become zero during the evaluation of
the decimal assignment command.
----------------------------------------------------------------
3. There are only two kinds of variables. All Teapro variables
are either strings or decimal numbers. Most other languages have
a half dozen or more types of variables. Each of the variable
types can either be a variable or a constant of that variable
type. Each of the variable types can be a global variable or a
local variable.
----------------------------------------------------------------
4. The programmer can only write subroutines and not functions.
There are no functions in Teapro. Commands cannot be combined
together on one line as is done in languages which have
functions.
----------------------------------------------------------------
5. Values are passed from subroutine to subroutine using
generic global variables rather than with parameters.
----------------------------------------------------------------
6. Teapro programs are generally structured. While there are
the commands goto and gtag, without using them programs must be
strictly structured.
----------------------------------------------------------------
7. The program which is the Teapro interpreter is small, uses
few resources and requires no .DLL files other than those in the
operating system. The Teapro interpreter can be copied from
computer to computer by using a diskette. Since it is so small
it does not need a multi diskette installation. In fact, it does
not need to be installed at all. The Teapro interpreter and the
Teapro program to be run can be run off of a diskette.
----------------------------------------------------------------
8. The string handling commands do insert, delete and replace.
Other languages do not have each of these three. The two string
search commands in Teapro allow the programmer to search both
forwards and backwards in a string starting at any particular
byte. Strings can also be sorted not only as length one strings
but also as length greater than one strings.
----------------------------------------------------------------
9. Compares are single compares in the control commands dift,
dwhi, $ift, and $whi. In Teapro compares may not be strung
together with "and" or "or" as in other languages. Use nesting
to accomplish the same thing as multiple compares. Nesting of
compares is much easier to understand, and is much more
straightforward.
----------------------------------------------------------------
10. Teapro has two commands $pkd and dpk$ for turning decimal
numbers into strings of packed format and for the same reversed.
Older business languages such as COBOL and RPG store numbers in
records using this packed format. Packed decimal format is also
called binary coded decimal or BCD.
----------------------------------------------------------------
11. Expressions are generally not allowed in Teapro.
Expressions are algebraic problems which must be evaluated to
obtain the value needed. In Teapro you cannot use 3 * 8 to mean
24. The minus sign is an operator used only in the assignment
command.
----------------------------------------------------------------
----------------------------------------------------------------
Before getting into the console commands for the program
teapro.exe, the command line parameter needs to be explained. On
the command line after the program teapro.exe a parameter may be
placed, for example:

C:\TEST\teapro.exe tinytea.tea

What this will do is to load and run the program tinytea.tea
after the teapro.exe has started. Then, when the program
tinytea.tea has ended the teapro.exe interpreter will also end.

The Teapro program tinytea.tea is used for testing all of the
Teapro commands and for heavy prime number testing. It is used
for finding the prime numbers 5TP39, ie. 10 twin primes in 39
numbers.

It is not necessary to put the name of the Teapro program as a
parameter on the command line. If there is no parameter, the
interpreter teapro.exe will come up as a console application in
which case the following console commands may be performed.
----------------------------------------------------------------
DEBUG

This command is used to turn DEBUG on. In a teapro program
debug can be toggled with the dbug program command.
----------------------------------------------------------------
INFO

This command gives information about some of the limitations of
a teapro program such as total maximum program lines.
----------------------------------------------------------------
LOAD

Use this command to get the Teapro interpreter to ask for a
Teapro program name to be loaded.
----------------------------------------------------------------
RUN

This command runs the program that has just been loaded.
----------------------------------------------------------------
SHOW

This command allows you to show the loaded program to see how
the teapro prep has changed the original program in preparation
to having it ready to run. When in SHOW mode you can enter a
line number to begin listing at that line. You can enter subr to
list only the Teapro program subroutines.
----------------------------------------------------------------
----------------------------------------------------------------
In Teapro there are two kinds of variables. There are decimal
variables which are fifteen digit floating point variables.
There are strings which can be as long as 100,000,000
characters.

Variables can be global or local. Global variables can be seen
by all parts of the running Teapro program. Local variables can
be seen only within the subroutine in which they are defined.

Global decimal variables have names which begin with DG_ with
the rest of the variable name made up of letters and numbers.
Local decimal variables have names which begin with d_ with the
rest of the variable name made up of letters and numbers. Either
upper or lower case is OK. Variable names must be at least five
characters long but may be upto about sixty long.

Global string variables have names which begin with sg_ with
the rest of the variable name made up of letters and numbers.
Local string variables have names which begin with s_ with the
rest of the variable name made up of letters and numbers. Either
upper or lower case is OK. Variable names must be at least five
characters long but may be upto about sixty long.

Case of commands and variable names does not matter in Teapro.
Names such as d_any, D_ANY, d_Any, D_aNy, etc. are all the same
in Teapro.

Literal numbers can only have upto five digits with no decimal.
They may have a + or - sign in front of them that does not count
towards the length of 5.

"hello world" is a string literal.
Also, #hello world# is a string literal.

In this booklet, variables and commands will generally be given
in lowercase so they will stand out.
----------------------------------------------------------------
----------------------------------------------------------------
The decimal assignment expression:

d_number = - d_total * 3 + d_any / -14 % 2 \ d_dot

The above is a decimal assignment command expression. In Teapro
only the decimal assignment command can have a decimal
expression. Only the operators +, -, *, /, %, \, @, ? can be
used. These operators have the following meanings:

+ means to add term1 and term2
- means to subtract term2 from term1
* means to multiply term1 and term2
/ means to divide term1 by term2
% means round and find modulus of term1 using absolute of term2.
  The sign of a mod result is the same as the mod of term.
\ means round both and do an integer divide term1 by term2
^ means raise term1 to power term2.
@ means to round term1 to number of decimal positions in term2.
? means to truncate term1 to number of decimal positions in term2.

A decimal assignment expression may be upto 200 bytes in
length. The operations are done strictly left to right. Here is
an example:

$tod d_number, "-123,456,789.012345"
d_answer = d_number * -45218

You cannot use a number like -123,456,789.012345 in a decimal
assignment expression, so you must put it into a decimal
variable and then use that variable in the decimal assignment
expression.

Note that there is no command in the decimal assignment command
line. When the program is running it puts dset in front of the
decimal assignment command line. You can use dset as the command
in front of your decimal assignment expressions but it is not
needed. For example:
dset d_answer = d_number * -45218
----------------------------------------------------------------
The string expression:

s_string = "Count=" + d_count + ", string=" + s_any

The above is the string assigment command with a string append
expression. A string append expression can be used as the last
parameter with five Teapro commands. These are
$app,$inp,$out,$sho and the string assignment command.

Note that in the string assignment command that there is no
actual command. The program automatically puts $set in front of
the string assignment command when preparing a Teapro program to
run. You can use $set but it is not needed. For example:
$set s_any = s_dot + " HELLO THERE " + # AGAIN # + " 123.45"

Note here that you can enclose literal strings in either " or
#. In this way if you need either of them in a literal string
you can use the other one to enclose the string.
----------------------------------------------------------------
----------------------------------------------------------------
dabs d_result, d_number

Absolute value. Put the absolute value of d_number into
d_result.
----------------------------------------------------------------
darc d_radians, d_sin

Get the arcsine of a number. Put the arcsine of sine d_sin into
d_radians. d_sin is made to be 1 if greater than 1 and is made
to be -1 if less than -1.
----------------------------------------------------------------
dbad d_number1 >= d_number2

Bad decimal variable test. If the condition is true, then we
have an error and the running Teapro program will end. dbad is
quick and is to be used only for testing for near disaster
situations. Any of the standard tests can be used ie. <, >, =,
<=, >=, <>.
----------------------------------------------------------------
dbug

The teapro command dbug gives immediate access to all of the
variables and various numbers that control the running of the
current running teapro program. It can be used as the result of
a dift so that it only comes up under certain circumstances. By
rights it should be EBUG instead since it is more of a control
or information giving command. The opportunity to name a command
dbug was just too much to resist.
----------------------------------------------------------------
dch$ s_string, d_char, d_long

Decimal character to string. Make a string s_string of the
character corresponding to d_char of length d_long.
----------------------------------------------------------------
dcut d_number, s_string, d_begIN, d_long
Cut a number from a string. Cut d_number from s_string
beginning at byte d_begIN for length d_long or stop when a
non-number occurs. This is very similar to $cut.
----------------------------------------------------------------
ddec d_decimal

Decrement d_decimal by 1.
----------------------------------------------------------------
dduo d_factor, d_1quadpart, d_1quadmult

Test a number for primeness and also that number plus two with
one command. dduo has the exact same format as dfak. In other
words, is the number the first of a prime duo? Following is the
info for dfak. If d_factor ends up with a 1 in it then we have a
prime duo or twin.

Find the lowest factor of a test number such that d_1quadpart
is the part of the test number less than 1E15 and d_1quadmult is
the number of quadrillions, ie. 1E15, of the test number. For
example, suppose the test number is 123,456,789,012,345,678,901.
The part below 1E15 is 789,012,345,678,901 and this would be put
into d_1quadpart as it is the PART below 1E15. Into d_1quadmult
we would need to put 123,456 as it is the number of
quadrillions, ie 1E15. This test number has a d_factor of 11.
Another test number is 108,000,000,000,000,001. Into d_1quadpart
we put 1. Into d_1quadmult we put 108. dfak gives 1 for d_factor
meaning that this test number is prime. dfak will work for sure
only if d_1quadmult is 1,604,388 or less. The whole number must
be 1,604,388,996,928,588,480,512 or less.

This is the Teaquad method of testing large numbers for
primeness.
----------------------------------------------------------------
ded$ s_string, d_decimal, d_long, d_places

Decimal edit to string. Change d_decimal into string s_string,
and give it a total length of at least d_long bytes, right
justified. Show the number of decimal positions in d_places.
Separate 1000's with commas. The command dto$ is the same but
does not put in commas. If d_long and d_places are both zero
then the number will be its natural length with no leading zeros
and no trailing zeros to the right of the decimal.
----------------------------------------------------------------
dfac d_factor, d_number

Find the lowest integer factor of d_number greater than one and
put it in d_factor. If there are none greater than one put one
in d_factor. If d_factor ends up with one then d_number is
prime. dfac only works for numbers less than 2^53 or
9,007,199,254,740,992. For large numbers upto 4E20 use the
Teapro command dfak.
----------------------------------------------------------------
dfak d_factor, d_1quadpart, d_1quadmult

Find the lowest factor of a test number such that d_1quadpart
is the part of the test number less than 1E15 and d_1quadmult is
the number of quadrillions, ie. 1E15, of the test number. For
example, suppose the test number is 123,456,789,012,345,678,901.
The part below 1E15 is 789,012,345,678,901 and this would be put
into d_1quadpart as it is the PART below 1E15. Into d_1quadmult
we would need to put 123,456 as it is the number of
quadrillions, ie 1E15. This test number has a d_factor of 11.
Another test number is 108,000,000,000,000,001. Into d_1quadpart
we put 1. Into d_1quadmult we put 108. dfak gives 1 for d_factor
meaning that this test number is prime. dfak will work for sure
only if d_1quadmult is 400,000 or less.

This is the Teaquad method of testing large numbers for
primeness.
----------------------------------------------------------------
dift d_decimal1 = d_decimal2
dift d_decimal1 = d_decimal2: $out "hello there"

If d_decimal1 equals d_decimal2 then perform all of the command
lines down to the matching else or endi command. If they do not
equal then jump down to the appropriate else or endi command.

If the dift command line is followed with a colon and another
command line, then the dift command line conditions only that
other command line. That other command line may not be a control
command.

You may use any of the following compare options with dift: =,
>, >=, <, <= or <>.
----------------------------------------------------------------
dinc d_decimal

Decimal increment. Increment d_decimal by one.
----------------------------------------------------------------
dlog d_log, d_number

Logarithm of base 10. Put the common or base 10 logarithm of
d_number into d_log. d_number is made positive if negative and
d_log is zero if d_number is zero.
----------------------------------------------------------------
dpk$ s_string, d_decimal, d_long

Decimal number to a packed format string. Round d_decimal to a
whole number and then change it into a string of packed format
of length d_long. Packed decimal format is also called binary
coded decimal or BCD.
----------------------------------------------------------------
dpow d_result, d_number, d_power

Raise d_number to power d_power and put into d_result. d_number
must be greater than zero. If d_number is negative and d_power
is not an integer then make d_number positive first.
----------------------------------------------------------------
dran d_random

Put a decimal random number between 0 and 1 in d_random.
----------------------------------------------------------------
drou d_new, d_old

Round decimal number to integer. Round decimal number d_old and
put the result in d_new. A decimal amount of 0.5 is rounded away
from zero.
----------------------------------------------------------------
dsec d_seconds

Put seconds in d_seconds. This is used to time various events.
The difference between two calls of this command will be the
time in seconds that has passed.
----------------------------------------------------------------
dsin d_sin, d_radians

Sine of a number. Put the sine of number d_radians which is an
angle in radians into d_sin. If d_radians > 2*PI then d_radians
is made to be 2*PI. If d_radians < -2*PI then d_radians is made
to be -2*PI.
----------------------------------------------------------------
d_result = -d_num1 * d_num2 - d_num3 / d_num3 % d_num4 \ d_num5
dset d_result = -d_num1 * d_num2 - d_num3 / d_num3 % d_num4 \ d_num5

Decimal set. The right side is evaluated strictly left to
right. It is preferred here to omit the dset command altogether.
The operators are:

+ is add
- is subtract
* is multiply
/ is divide
% is round both to an integer and find the mod.
  The sign of a mod result is the same as the mod of term.
\ round both to an integer and do an integer divide.
^ means to raise to a power.
@ means to round to a number of decimal places.
? means to truncate to a number of decimal places.

Literal numbers can be used as the decimal variables are used
if the numbers are -99999 to +99999 with no decimal places.
----------------------------------------------------------------
dsys d_amount, d_number

Decimal system info.
d_number=1 means put total string length in d_amount.
d_number=2 means put lines of Teapro done in d_amount.
d_amount=3 means put total line length of program in d_amount.
----------------------------------------------------------------
dto$ s_string, d_decimal, d_long, d_places

Decimal to string. Change d_decimal into string s_string, and
give it a total length of at least d_long bytes, right
justified. Show the number of decimal positions in d_places. Do
not put in commas as in ded$. If d_long and d_places are both
zero then the number will be its natural length with no leading
zeros and no trailing zeros to the right of the decimal.
----------------------------------------------------------------
dtof s_string, d_decimal, d_long

Decimal to field. Change decimal d_decimal into a string
s_string of length d_long such that s_string begins with + or -,
is right justified and zero filled. This format is needed many
times for a field in a record. The decimal d_decimal is rounded
to a whole number.
----------------------------------------------------------------
dtoi d_index, d_decimal

Decimal to index. Put the decimal d_decimal into the array of
decimals at index d_index. The array of decimals has 96000
decimals with the index ranging from 1 to 96000. If the index
d_index is outside of this range an error will occur and the
running Teapro program will end. Other decimal array commands
are arrz, addi, itod.
----------------------------------------------------------------
dtru d_new, d_old

Truncate decimal number. Truncate decimal number d_old and put
the result in d_new. If d_old is not an integer, d_new will be
closer to zero than d_old.
----------------------------------------------------------------
dwhi d_decimal1 < d_decimal2

Decimal while. While d_decimal1 is less than d_decimal2 perform
the lines of commands down to the matching endw; otherwise, jump
to line right after the endw. The following compares can be use:
=, >, >=, <, <= and <>.
----------------------------------------------------------------
----------------------------------------------------------------
$app s_string1, s_string2

String append. Put s_string1 + s_string2 into s_string1. The
string s_string2 can be a string append expression. Creating a
string longer than 100,000,000 bytes will cause an error.
----------------------------------------------------------------
$bak d_byte, s_lookin, d_start, s_lookfor

Back lookup. Using s_lookin starting at byte d_start backwardly
search or look for s_lookfor. If it is found put the number of
the first byte into d_byte and if it is not found put zero into
d_byte.
----------------------------------------------------------------
$bes s_new, s_old

Blank escape characters in s_old and store the string in s_new.
An escape character is one whose number is less than 32.
----------------------------------------------------------------
$ch$ s_new, s_char, d_long

String character to string. Make s_new of length d_long of the
first character of s_char. Creating a string longer than
100,000,000 bytes will cause an error.
----------------------------------------------------------------
$chd d_char, s_char

String character to decimal. Find the character number of the
first character of s_char and put that number into d_char.
----------------------------------------------------------------
$clo s_new, s_old

Make case lower. Make s_old lower case and store in s_new.
----------------------------------------------------------------
$cnt d_count, s_string, s_find

Put count of occurrences of s_find in s_string into d_count.
Occurrences cannot overlap.
----------------------------------------------------------------
$cod s_new, s_old

Code s_old into s_new. Code and decode are the same operation.
This is an entirely different type of encryption from $toe.
----------------------------------------------------------------
$cup s_new, s_old

Case make upper. Make s_old uppercase and store in s_new.
----------------------------------------------------------------
$cut s_partstring, s_wholestring, d_byte, d_long

Cut string from string. Put into s_partstring a portion of
s_wholestring starting at byte d_byte for length d_long.
----------------------------------------------------------------
$dat s_date

Put the date as a string into s_date. The date string contains
the date and time in two formats:
"22-MAR-2002 21:28:16 20020322212816".
----------------------------------------------------------------
$del s_string, d_beg, d_long

String delete. In string s_string starting at d_beg delete the
bytes for a length of d_long.
----------------------------------------------------------------
$dot d_dot, s_string1, s_string2, d_which

Find certain string occurrence and put location in d_dot. Find
occurrence d_which of s_string2 in s_string1 and put the number
of the first byte of that occurrence into d_dot. Occurrences of
s_string2 cannot overlap a previous occurrence. If the wanted
occurrence of the wanted string is not found then put zero into
d_dot.
----------------------------------------------------------------
$hsh d_hash, s_string

String hash. Create a hash number d_hash that is fairly unique
for the string s_string. The hash decimal number d_hash can be
15 digits long. The first 9 are merely a total of the char
numbers of the bytes in the file. The last six represent a total
of the char numbers times the positions in records which are 701
bytes long. 701 is prime. Char numbers run from 1 to 256 for
these calculations.
----------------------------------------------------------------
$ift s_string1 = s_string2
$ift s_string1 = s_string2: $out "hello world"

If s_string1 equals s_string2 then perform all of the command
lines down to the matching else or endi command. If they do not
equal then jump down to the appropriate else or endi command.

If the command line beginning with $ift ends with a colon and
another command line, then only that other command line is
conditioned by the $ift. That other command line must not be a
control command.

You may use any of the following compare options with $ift:
=  is equal to
<  is less than
<= is less than or equal to
<> is not equal to
>  is greater than
>= is greater than or equal to
----------------------------------------------------------------
$inp s_input, s_output

Output s_output to screen and input from the keyboard s_input.
s_output can be a string expression. For security, the maximum
length of s_input for $inp is 1024 bytes for security.
----------------------------------------------------------------
$ins s_wholestring, d_byte, s_partstring

Insert string into string. Insert into s_wholestring starting
at byte d_byte the string s_partstring. If d_byte is the length
of s_wholestring plus one then s_partstring is appended at the
end. Creating a string longer than 100,000,000 bytes will cause
an error.
----------------------------------------------------------------
$isc d_yesno, s_string, s_char

String is a string of characters s_char? If s_string is a
string of the first character of s_char then put 1 in d_yesno
else 2.
----------------------------------------------------------------
$isd d_yesno, s_string

String is decimal. If string s_string is a decimal number then
put 1 in d_yesno otherwise put 2 in d_yesno.
----------------------------------------------------------------
$isp d_yesno, s_string, s_pattern

String s_string is a type pattern match with string s_pattern.
Compare s_string and s_pattern to see if the pattern of types
match. If yes then put a 1 in d_yesno. If not put a 2 in
d_yesno. Types of characters are: escapes, blanks, punctuation,
numbers, uppers, lowers, and char greater than #126. The two
strings must also be the same length.
----------------------------------------------------------------
$ist d_yesno, s_string, s_type

String s_string is made up of characters of the same type as
the first character of s_type. If yes then put 1 in d_yesno. If
no then put 2 in d_yesno. Types of characters are: escapes,
blanks, punctuation, numbers, uppers, lowers, and char greater
than #126.
----------------------------------------------------------------
$len d_long, s_string

String length. Put length of string s_string into d_long.
----------------------------------------------------------------
$lok d_byte, s_wholestring, d_start, s_partstring

Look for s_partstring in s_wholestring starting at byte
d_start. If it is found put the beginning byte number in d_byte.
If it is not found put zero in d_byte.
----------------------------------------------------------------
$off s_result, s_string, d_long

Cut off end of string s_string for d_long bytes and store it in
s_result.
----------------------------------------------------------------
$out s_output

String out. Output to the screen s_output. s_output can be a
string expression made up of string variables and literals as
well as decimal variables. $out does a carriage return and line
feed at the end to move the line up.
----------------------------------------------------------------
$par s_toextract, s_csv, s_char, d_which

Parse a string. Extract string s_toextract from the character
separated value string s_csv indicated by number d_which.
Strings in s_csv are separated by occurrences of s_char. The
length of s_char must be 1. If d_which=1 then return the string
ending with the first occurrence of s_char. If d_which=6 return
the string ending with the sixth occurrence of s_char.
----------------------------------------------------------------
$pkd d_yesno, d_decimal, s_string

String in packed format to decimal. Convert the packed format
number in s_string into a whole number decimal d_decimal. Packed
decimal format is also called BCD or binary coded decimal. If
s_string can be converted to a decimal number put 1 in d_yesno
otherwise put 2 in d_yesno.
----------------------------------------------------------------
$rep s_wholestring, d_byte, s_partstring

Replace part of a string with another string. In s_wholestring
starting at byte d_byte replace the bytes with s_partstring. The
length of s_wholestring is never changed by this command.
----------------------------------------------------------------
$set s_string1 = s_string2 + " hello there " + s_string3 + # WOW #

String set. This is the string assignment command in Teapro. It
is actually preferred to omit the $set command at the beginning.
Notice that string literals may be enclosed in double quotes or
pound signs.
----------------------------------------------------------------
$sho s_output

String show. Output to the screen s_output. s_output can be a
string expression made up of string variables and literals as
well as decimal variables. $sho does not do a carriage return
and a newline afterwards.
----------------------------------------------------------------
$sor s_new, s_old, d_long

Sort string. Sort the string s_old into string s_new by
sections each d_long in length.
----------------------------------------------------------------
$swp s_string, s_old, s_new

String swap. In s_string replace each occurrence of s_old with
s_new.
----------------------------------------------------------------
$sys s_info, d_which

System or program information to s_info depending on d_which.
1 = path and filename of this running Teapro Interpreter
2 = current subroutine name of Teapro program
3 = version of current Teapro program
4 = name of current loaded Teapro program
----------------------------------------------------------------
$tlo s_new, s_old

String trim low. Trim string s_new and make lower case. Then
put it into s_old.
----------------------------------------------------------------
$tod d_decimal, s_string

String to decimal. Convert the string in s_string to a decimal
number and store it in decimal variable d_decimal. If s_string
cannot be converted to a decimal number an error occurs.
Usually, one should use $isd to test s_string first to see if it
can be converted to a decimal.
----------------------------------------------------------------
$toe s_new, s_old, s_key, d_which

String to encoded. Code s_old into s_new using key s_key. If
d_which=1 encode. If d_which=2 then decode. s_key must be
letters and numbers, and is not case sensitive. This encryption
is about 29 bit in strength which makes it pretty weak. There
are only about 700,000,000 possible keys. This is an entirely
different type of encryption from $cod. This encryption is
called OldToe.
----------------------------------------------------------------
$toi d_index, s_string

String to index. Put the string s_string in the array of
strings at index d_index. The array of strings has 2000 strings
with the index ranging from 1 to 2000. If the index d_index is
outside of this range an error will occur which will cause the
running Teapro program to end. s_string cannot be a string
append expression.
----------------------------------------------------------------
$trb s_new, s_old

Trim the blanks and escape characters from both ends of s_old
and put the string in s_new.
----------------------------------------------------------------
$trl s_new, s_old

Trim the blanks and escape characters from the left end of
s_old and put the string in s_new.
----------------------------------------------------------------
$trr s_new, s_old

Trim the blanks and escape characters from the right end of
s_old and put the string in s_new.
----------------------------------------------------------------
$tup s_new, s_old

Trim string s_old and make it upper case. Then put it in s_new.
----------------------------------------------------------------
$whi s_string1 > s_string2

String while command beginning a while block which ends with
endw. The comparison can be >,=,<,>=,<=, or <>. If the
comparison is true the while loop continues. If the comparison
is not true the block is skipped over and the line under the
endw is processesed next.
----------------------------------------------------------------
----------------------------------------------------------------
itod d_decimal, d_index

Index to decimal. Get the decimal that is in the array of
decimals at index d_index and put that decimal in d_decimal. The
array of decimals has 96000 decimals with the index ranging from
1 to 96000. If the index d_index is outside of this range an
error will occur and the running Teapro program will end. Other
decimal array commands are: arrz, addi, dtoi.
----------------------------------------------------------------
ito$ s_string, d_index

Index to string. Get the string that is in the array of strings
at index d_index and put that string in s_string. The array of
strings has 2000 strings with the index ranging from 1 to 2000.
If the index d_index is outside of this range an error will
occur which will end the running Teapro program.
----------------------------------------------------------------
----------------------------------------------------------------
else

else is the bottom of a dift command and allows the opposite of
the condition of the dift lines performed.
----------------------------------------------------------------
endi

End if. This is the bottom of a dift or else command.
----------------------------------------------------------------
endp

End program.
----------------------------------------------------------------
ends sub_calculate

End subroutine sub_calculate. This ends the subroutine begun
with a subr line somewhere above this ends line.
----------------------------------------------------------------
endw

End while. endw is the bottom command for a while loop.
----------------------------------------------------------------
esub sub_calculate

Exit to subroutine sub_calculate. The command esub may be
omitted in the above line.
----------------------------------------------------------------
----------------------------------------------------------------
fadd d_long, s_file, s_record

File add. Add a record s_record to the end of file s_file and
put a line feed character on the end. Put the total length added
to the file in d_long. The maximum length of the data that can
be written is 4096. If the command succeeds, the length written,
d_long, to the file will be one more than the length of
s_record. Use the command fapp to add a record to the file with
a carriage return and a line feed added to the end.
----------------------------------------------------------------
fapp d_long, s_file, s_record

File append. Append a record s_record to the end of file s_file
and put a carriage return and a line feed character on the end.
Put the total length added to the file in d_long. The maximum
length of the data that can be written is 4096. If the command
succeeds, the length written, d_long, to the file will be two
more than the length of s_record. Use the command fadd to add a
record to the file with just a line feed on the end.
----------------------------------------------------------------
fdel d_yes, s_file

File delete. Delete the file named in s_file. If the file is
deleted put 1 in d_yes else put 2 in d_yes.
----------------------------------------------------------------
finp s_record, s_file

File input. The file name is in s_file. Input that entire file
into the string s_record. If the length of the file is greater
than 100,000,000 bytes an error will occur.
----------------------------------------------------------------
flen d_long, s_file

File length. Find the length in bytes of the file named in
s_file and put it into d_long. If the file cannot be accessed or
cannot be found put -1 in d_long.
----------------------------------------------------------------
fout d_byteS, s_file, s_record

File output. The string to be outputted is in s_record. Output
the entire string into the file whose name is in s_file. The
total number of bytes written goes in d_byteS. The entire file
will consist of what was in s_record.
----------------------------------------------------------------
frea s_record, s_filename, d_byte, d_long

File read. Read from the file named in s_file starting at byte
d_byte for length d_long and put that record into s_record. In
Teapro the first byte of a file is byte 1. If the file read
fails for some reason the resulting string will have less length
than hoped for. The maximum length of the data read can be 4096
bytes.
----------------------------------------------------------------
fren d_yes, s_file2, s_file1

File rename. Rename the file named in s_file1 to the name in
s_file2. If the file is renamed put 1 in d_yes else put 2 in
d_yes.
----------------------------------------------------------------
fsip s_record, s_file, d_filebyte

File sip. Sip or read a variable length record s_record
starting at d_byte and ending in a line feed from file s_file
and remove the line feed. Put the beginning of the next record
into d_filebyte. If no record was read put zero in d_filebyte.
Zero length records are possible. You must put 1 in d_filebyte
for the first read. The maximum length of the data read is 4096
bytes. Variable length records in files end with a line feed
which means they end with character = 10. The command fsip
blanks escape characters in s_record.
----------------------------------------------------------------
fwri d_long, s_filename, d_byte, s_record

File write. Write to the file named in s_file starting at byte
d_byte the string in s_record. The number of bytes written goes
in d_length. In Teapro the first byte of a file is byte 1. The
maximum length of the data written can be 4096 bytes.
----------------------------------------------------------------
----------------------------------------------------------------
addi d_index, d_decimal

Add to decimal array at index. Add decimal d_decimal to decimal
array value at d_index and put total back in decimal array at
d_index. The decimal array index d_index cannot be less than 1
or greater than 96000. Other decimal array commands are arrz,
dtoi, itod.
----------------------------------------------------------------
arrb

Blank the string array. Use arrz to zero the decimal array. The
string array holds 2000 strings with the index ranging from 1 to
2000.
----------------------------------------------------------------
arrz

Zero the decimal array. Use arrb to blank the string array. The
decimal array holds 96000 decimals with the index ranging from 1
to 96000. Other decimal array commands are addi, dtoi, itod.
----------------------------------------------------------------
gtag tag_top1

This is the tag that the command "goto tag_top1" goes to. Both
have to be in the same subroutine. gtag names begin with "tag_"
and are local to the subroutine they are in.
----------------------------------------------------------------
goto tag_top1

Go to the line which has "gtag tag_top1" on it. Both have to be
in the same subroutine. Each gtag line can have many
corresponding goto lines.
----------------------------------------------------------------
subr sub_calculate

Subroutine sub_calculate begins with this line.
----------------------------------------------------------------
vari s_string, d_decimal, s_this, d_that

Variable define. The vari command defines variables either
global or local. It can only occur at the very top of the
program, to declare global variables, or at the top of a
subroutine, to declare local variables.
----------------------------------------------------------------
Recently added to Teapro are the goto and gtag commands. These
work in the following fashion.
----------------------------------------------------------------
goto tag_someplace
... various lines of the program
gtag tag_someplace
... various lines of the program
goto tag_someplace
----------------------------------------------------------------
When the command goto is encountered with the tag of
tag_somplace, the program shifts to the location of the gtag
command with the tag of tab_someplace.

The program then resumes processing at the program line
following the gtag tag_someplace line. The tag name must begin
with "tag_" and only one tag with that name may exist in a
subroutine.

There can be several goto commands with the same tag name in a
subroutine. One cannot use the goto command to exit or enter a
subroutine.

Persons familiar with the advantages of structured programming
will know that the goto, gtag commands are not necessary. They
were added to Teapro so that languages that use them can be more
easily translated into Teapro.

Many languages have the CONTINUE or the BREAK commands. These
are really just the goto command with some unclearness as to
where the corresponding gtag line is.

Even languages without those two commands have some kind of
else and endw which are really just the goto command. Even the
commands IF and WHILE which in Teapro are dift, $ift, dwhi, $whi
are just goto commands with a condition.
----------------------------------------------------------------
----------------------------------------------------------------
Suppose we have a number: 123,456,789,012,345,678,901, so, how does
the Teaquad Method work to use floating point numbers called double
numbers in the C programming language to find the modulus of such a
number while treating the floating point numbers as integers?

We will give the computer code in Teapro.
But we will write the numbers in comma notation or in exponential
notation so that they will be readable.
We will put the modulus of the number by d_divisor into d_mod.
Brief explanations are included just before each line.
----------------------------------------------------------------
First define the seven variables as decimal numbers in Teapro.
vari d_mult,d_part,d_mod,d_num1,d_num2,d_num3,d_num4

Then set the Mult variable d_mult and the Part variable d_part.
d_mult = 123,456
d_part = 789,012,345,678,901

Then multiply the Mult variable by 5,000,000,000 which is 5E9.
d_num1 = d_mult * 5E9

Then find the modulus of that by d_divisor which can be any integer
upto the square root of our beginning number.
d_num2 = d_num1 % d_divisor

Then multiply that by 200,000 or 2E5.
d_num3 = d_num2 * 2E5

Then add the Part to it.
d_num4 = d_num3 + d_part

Then find the modulus of that by d_divisor.
d_mod = d_num4 % d_divisor

We now have the modulus of our number by d_divisor. The d_divisor
can be any integer upto the square root of our starting number.
The limit on the number is that d_num1,d_num3, and d_num4 cannot be
over 2^53-1 which is: 9,007,199,254,740,991.
----------------------------------------------------------------
----------------------------------------------------------------
In Teapro you cannot call operating system commands. This is a
major security feature.

In Teapro you cannot call another Teapro program. This, too, is
for security.

Teapro does not have pointers.

A Teapro program has definite limitations so that you know
ahead of time what you cannot do.
----------------------------------------------------------------
----------------------------------------------------------------
The OpenTea technology recognizes that there must be limits in
programs. Teapro has the limits set so that the programmer can
know what they are.

The maximum number of lines in a Teapro program is 18000.
However, two commands take up two lines each. These are the
control command lines beginning with $ift or dift when followed
by a colon and another command line. Also, each subroutine has
one line added when Teapro preps the program to be run.
Remember, that comment lines and blank lines do not count
towards the limit of 18000 lines.

For each subroutine, one line is added to the program in
memory. This line is added under the last vari command. This
line tells the Teapro interpreter how many local decimal and
string variables there are in that subroutine.

The maximum depth of the subroutines that can be called is
1000. The part of the program which is not actually in a
subroutine counts as 1 towards this count, also.

The maximum number of subroutines that may be in a Teapro
program is 1000.

The maximum depth to which dift, dwhi, $ift and $whi control
commands may be nested is 1000.

Variable names must be at least five characters long and no
more that sixty-four characters long.

Please remember that Teapro commands are case independent. In
this webpage they are shown in lower case for simplicity.

String variables can be no longer than 100,000,000 bytes.
Decimal variables have fifteen significant figures regardless of
where the decimal is placed.

Teapro has no extensibility for adding other commands or parts
of other languages. Most other programming languages have this
capability which makes them far less secure and immensely more
complex.

The Teapro programming language has no way of producing a list
of files that are in a particular directory. There is no command
that does this, and this is deliberate to make Teapro simpler
and more solid. A Teapro program can ask the user for a file
name or it can be hard coded into the program. For the type of
programming that Teapro is suitable for, this is sufficient and
much simpler than other languages.

There is no way to type in a Teapro program into the Teapro
interpreter. A Teapro program must be entered into a text file
and then that file loaded by the Teapro interpreter.
----------------------------------------------------------------
A Teapro program can be no more than 18000 lines. The actual
count of program length will be less than this because each
subroutine when it is prepped adds one line. Also, the dift and
$ift colon lines are each broken into two lines. Comment lines
do not count toward the program length. Comment lines begin with
an apostrophe or a less than sign ie. <.
----------------------------------------------------------------
There are 4000 maximum string variables and string literals.
There are 2000 maximum decimal variables and decimal literals.
The decimal array has 96000 elements numbered 1 to 96000.
The string array has 2000 elements numbered 1 to 2000.
----------------------------------------------------------------
Strings are limited to length 100,000,000 in teapro. Any length
from 0 to 100,000,000 is fine, but if you try to make a string
longer than that an error message will come up and the currently
running teapro program will end.
----------------------------------------------------------------
----------------------------------------------------------------
These two commands are used to test numbers for lowest factors.
Usually, this is done to see if the lowest factor is 1 which
means that the number is prime. Here is the format of these
commands.
----------------------------------------------------------------
dfac d_factor, d_number
dfak d_factor, d_1quadpart, d_1quadmult
dduo d_factor, d_1quadpart, d_1quadmult
----------------------------------------------------------------
dfac finds the lowest factor of d_number and puts it in
d_factor. Before finding the factor, dfac makes d_number
positive and a whole integer. The maximum limit on d_factor is
9,007,199,254,740,992 which is 2 raised to the 53rd power.
----------------------------------------------------------------
dduo finds the lowest divisor of that number or the number two
above it, whichever divisor is greater. dduo is used to test for
prime duos or twins.
----------------------------------------------------------------
For dfak the number to be tested must be broken into two
numbers. Put the amount less than 1 quadrillion, ie. less than
1E15, into d_1quadpart. Put the number of quadrillions in
d_1quadmult. The question here is how big can the number of
quadrillions be that goes into d_1quadmult? Well, it can be at
least 1,604,388 with absolute safety. This means that dfak can be
used to test a number upto 1,604 quintillion to see if it is
prime. Actually, it will work for numbers as great as
1,604,388,996,928,588,480,512 but not larger!

This is the Teaquad method of testing large numbers for
primeness.
----------------------------------------------------------------
----------------------------------------------------------------
On the website teapro.com, down at the bottom are links to
download the following files which have to do with Teapro.

teapro4.html: this is this webpage about the language Teapro.

teapro.cpp: this is the C90 source code for the Teapro interpreter
teapro.exe: 32-bit console Teapro interpreter program for Windows.
teapro.o: Teapro interpreter for OS X for Mac computers

tinytea.cpp: source code for the beta of next Teapro interpreter
tinytea.exe: beta version of new Teapro interpreter for Windows.
tinytea.o: Teapro interpreter for OS X for Mac computers

c90tea.cpp: C90 source code for an old reliable Teapro interpretor
c90tea.exe: old reliable 32-bit console Teapro interpreter
c90tea.o: Teapro interpreter for OS X for Mac computers

oklatea.cpp: Teapro interpreter C90 public domain source code
oklatea.exe: 32-bit console Teapro interpreter from oklatea.cpp
oklatea.o: Teapro interpreter for OS X for Mac computers

teapro9.pas: Delphi source code for the Windows Teapro interpreter
teapro9.exe: Teapro interpreter for Windows written in Delphi

tinytea.tea: Teapro program to test out all Teapro commands.
oklatiny.tea: Teapro program to test out all Teapro commands.

newprime.tea: Teapro program to find prime numbers, 5TP39, PNQ30.
teaprime.tea: Teapro program to find prime numbers, 5TP39, PNQ30.
oklaprim.tea: Teapro program to find prime numbers, 5TP39, PNQ30.
valprime.tea: Teapro program to test find 5TP39s.

fixran.tea: Teapro program used to maintain this webpage book.
oklafix.tea: Teapro program used to maintain this webpage book.

teasho.tea: Teapro program with various utility capabilities.
oklasho.tea: Teapro program with various utility capabilities.

teaword.tea: Teapro program to do certain things with words.
teatest.tea: Teapro program to test various things.
teatry.tea: Teapro program to test some things.
teamath.tea: Teapro program to do great accuracy math.

teachess.tea: Teapro program that plays over chess games.
tea2move.tea: Teapro program that solves two move chess problems.
tea3move.tea: Teapro program that solves three move chess problems.
tea4move.tea: Teapro program that solves four move chess problems.
teabag.tea: Teapro program that plays various types of games.
----------------------------------------------------------------
The Teapro interpreter teapro.o was compiled on a Mac OS X using the
gcc compiler with the following line:
gcc teapro.c -o teapro.o -lm -O4
If you have downloaded teapro.o from the internet you can run it in
a Terminal window. First in that window you may have to do the
following command:
chmod u+x teapro.o
This will change the permission to execute on.
----------------------------------------------------------------
The Teapro interpreter teapro.exe was compiled as a console
application using the Borland C++ Builder 1.0 for Windows. It
also compiles using gcc on Linux or the Mac OS X and runs the
same.
----------------------------------------------------------------
The Teapro interpreter teapro9.exe was compiled as a Windows
GUI program using Borland Delphi Professional 2.0. It is now
completely obsolete as it has not been updated since 2005.
----------------------------------------------------------------
----------------------------------------------------------------
First, make sure the gcc compiler is installed. It comes with
additional software on the CD or DVD that the operating system
came on. To compile teapro.c on Linux or Mac OS X use the
following command in a console or terminal window.

gcc teapro.c -o teapro.o -lm -O4

-o means that what follows is exe name
-lm links in some necessary libraries
-O4 does maximum optimization

To run teapro on Linux or Mac OS X use the following command in
a console or terminal window.

./teapro.o
----------------------------------------------------------------
----------------------------------------------------------------
Ledgard, Henry and Marcotty, Michael, THE PROGRAMMING LANGUAGE
LANDSCAPE, Science Research Associates, Inc, Chicago, 1981.
----------------------------------------------------------------
Tucker, Jr, Allen B., PROGRAMMING LANGUAGES, Second Edition,
McGraw-Hill Book Company, New York, 1981.
----------------------------------------------------------------
****************************************************************
End of Webpage, 05-FEB-2014 19:50:45
Created by program: www.teapro.com/oklafix.tea