This section describes the basics of Small, as compiled and interpreted with Embryo.

This summary assumes that you are familar with C. For a full list of differences between C and Small, again, see the full documentation.\hypertarget{Small_Page_Small_Variables_Section}{}\doxysection{Variables}\label{Small_Page_Small_Variables_Section}
\hypertarget{Small_Page_Small_Type_Subsection}{}\doxysubsection{Types}\label{Small_Page_Small_Type_Subsection}
There is only one type, known as the \char`\"{}cell\char`\"{}, which can hold an integer.\hypertarget{Small_Page_Small_Scope_Subsection}{}\doxysubsection{Scope}\label{Small_Page_Small_Scope_Subsection}
The scope and usage of a variable depends on its declaration.

\begin{DoxyItemize}
\item A local variable is normally declared with the {\ttfamily new} keyword. E.\+g. 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{new} variable }
\end{DoxyCode}
 \item A static function variable is defined within a function with the {\ttfamily static} keyword. \item A global static variable is one that is only available within the file it was declared in. Again, use the {\ttfamily static} keyword, but outside of any function. \item A stock variable is one that may not be compiled into a program if it is not used. It is declared using {\ttfamily stock}. \item A public variable is one that can be read by the host program using embryo\+\_\+program\+\_\+variable\+\_\+find. It is declared using {\ttfamily public} keyword.\end{DoxyItemize}
Remember that the keywords above are to be used on their own. That is, for example\+:
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{public} testvar }
\end{DoxyCode}
 not\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{new} \textcolor{keyword}{public} testvar }
\end{DoxyCode}
\hypertarget{Small_Page_Small_Constants_Subsection}{}\doxysubsection{Constants}\label{Small_Page_Small_Constants_Subsection}
You can declare constants in two ways\+: \begin{DoxyItemize}
\item Using the preprocessor macro {\ttfamily \#define}. \item By inserting {\ttfamily const} between the keyword and variable name of a variable declaration. For example, to declare the variable {\ttfamily var1} constant, you type
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{new} \textcolor{keyword}{const} var1 = 2 }
\end{DoxyCode}
 Now {\ttfamily var1} cannot be changed.\end{DoxyItemize}
\hypertarget{Small_Page_Small_Arrays_Subsection}{}\doxysubsection{Arrays}\label{Small_Page_Small_Arrays_Subsection}
To declare an array, append square brackets to the end of the variable name. The following examples show how to declare arrays. Note the use of the ellipsis operator, which bases the array based on the last two declared values\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{new} msg[] = \textcolor{stringliteral}{"A message."}}
\DoxyCodeLine{\textcolor{keyword}{new} ints[] = \{1, 3, 4\}}
\DoxyCodeLine{\textcolor{keyword}{new} ints2[20] = \{1, 3\}         \textcolor{comment}{// All other elements 0.}}
\DoxyCodeLine{\textcolor{keyword}{new} ints3[10] = \{1, ... \}      \textcolor{comment}{// All elements = 1}}
\DoxyCodeLine{\textcolor{keyword}{new} ints4[10] = \{10, 20, ... \} \textcolor{comment}{// Elements = 10 -\/> 100.}}
\DoxyCodeLine{                               \textcolor{comment}{// The difference can be negative.}}
\DoxyCodeLine{\textcolor{keyword}{new} ints5[3][3] = \{\{1, 2, 3\}, \{4, 5, 6\}, \{7, 8, 9\}\}}
\end{DoxyCode}


\begin{DoxyNote}{Note}
Array initialisers need to be constant.
\end{DoxyNote}
\hypertarget{Small_Page_Small_Func_Calls_Section}{}\doxysection{Function Calls}\label{Small_Page_Small_Func_Calls_Section}
A typical function declaration is as follows\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{testfunc(param) \{}
\DoxyCodeLine{  \textcolor{comment}{// Do something ...}}
\DoxyCodeLine{  \textcolor{comment}{// over a couple of lines.}}
\DoxyCodeLine{\}}
\end{DoxyCode}


You can pass by reference. That is, the parameter you pass is changed outside of the function. For example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{testfunc(\&param) \{}
\DoxyCodeLine{  param = 10}
\DoxyCodeLine{  \textcolor{comment}{// The passed variable will be set to 10 outside of the function.}}
\DoxyCodeLine{\}}
\end{DoxyCode}


To pass an array\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{testfunc(param[]) \{}
\DoxyCodeLine{  \textcolor{comment}{// Do something to the array}}
\DoxyCodeLine{\}}
\end{DoxyCode}


\begin{DoxyNote}{Note}
Arrays are passed by reference.
\end{DoxyNote}
\hypertarget{Small_Page_Small_Control_Subsection}{}\doxysection{Control Structures.}\label{Small_Page_Small_Control_Subsection}
Small has the following control structures, which similar to their C counterparts\+: \begin{DoxyItemize}
\item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{if} (expression) statement1 \textcolor{keywordflow}{else} statement2 }
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{ \textcolor{keywordflow}{switch} (expression) \{}
\DoxyCodeLine{  \textcolor{keywordflow}{case} 0:}
\DoxyCodeLine{    statement1 \textcolor{comment}{// Can only be one statement.  Look Ma, no breaks!}}
\DoxyCodeLine{  \textcolor{keywordflow}{case} 1..3:   \textcolor{comment}{// For values between 1 and 3 inclusive.}}
\DoxyCodeLine{    statement2}
\DoxyCodeLine{  \textcolor{keywordflow}{default}:     \textcolor{comment}{// Optional}}
\DoxyCodeLine{    statement3}
\DoxyCodeLine{\}}
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{while}(expression) statement }
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{do} statement \textcolor{keywordflow}{while} (expression) }
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{for} (init\_expression; before\_iter\_test\_expression; after\_iter\_expression) statement }
\end{DoxyCode}
\end{DoxyItemize}
\hypertarget{Small_Page_Small_Preprocessor_Section}{}\doxysection{Preprocessor}\label{Small_Page_Small_Preprocessor_Section}
The following preprocessor directives are available\+: \begin{DoxyItemize}
\item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#assert constant\_expression }}
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#define pattern replacement }}
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#define pattern(\%1,\%2,...) replacement }}
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include filename }}
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{ \#if constant\_expression}}
\DoxyCodeLine{  \textcolor{comment}{// Various bits of code}}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{  \textcolor{comment}{// Other bits of code}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif }}
\end{DoxyCode}
 \item 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#undef pattern }}
\end{DoxyCode}
 \end{DoxyItemize}
