Added I/O to Manual

This commit is contained in:
ChrisFadden
2015-11-26 16:52:11 -05:00
parent e76bc51cce
commit ef53ad90c0
5 changed files with 191 additions and 138 deletions

View File

@@ -13,8 +13,9 @@
\usepackage{amsmath} % Required for some math elements
\renewcommand{\labelenumi}{\alph{enumi}.} % Make numbering in the enumerate environment by letter rather than number (e.g. section 6)
\usepackage{times} % Uncomment to use the Times New Roman font
\usepackage{times}
\usepackage{listings}
\usepackage{color}
%----------------------------------------------------------------------------------------
% DOCUMENT INFORMATION
%----------------------------------------------------------------------------------------
@@ -92,12 +93,65 @@ optional after declarations.
% SECTION 2: Functions
%----------------------------------------------------------------------------------------
\section{Functions}
Section func
\begin{lstlisting}[language=C++]
fun FunctionName(arg1 : arg1_type, arg2 : arg2_type) : returnType {
var result = arg1 + arg2;
return result;
}
\end{lstlisting}
Functions are declared using the {\bf{fun}} keyword. If you pass in
variables as shown, there will be passed by value, not by reference.
Therefore if you pass a variable in, it will not be modified outside the
function.
%----------------------------------------------------------------------------------------
% SECTION I/O
%----------------------------------------------------------------------------------------
\section{Input and Output}
In order to print to a terminal or file, the {\bf{io}} library must be
imported. There are a few different functions you can use to print to the
terminal.
The print() function will print out to the terminal without a newline
character. Like java, there is a println() function that will print whatever
you pass in, as well as a newline. There are also functions that can print
colors in a unix terminal. The color will continue when you print until
you call the function Reset().
\begin{enumerate}
\item {\color{red}{BoldRed()}}
\item {\color{green}{BoldGreen()}}
\item {\color{yellow}{BoldYellow()}}
\item {\color{blue}{BoldBlue()}}
\item {\color{magenta}{BoldMagneta()}}
\item {\color{cyan}{BoldCyan()}}
\end{enumerate}
\begin{lstlisting}[language=C++]
io::print(3.2); //print without a newline character
io::println(varA); //print variable A with a newline character
io::BoldRed();
io::println("This line is printed Red");
io::Reset();
io::println("This line is printed black");
\end{lstlisting}
You can also use kraken to read and write to files. The functions are as
follows:
\begin{lstlisting}[language=C++]
//returns true if file exists
var ifExists = io::file_exists("/usr/bin/clang");
//read file into string
var fileString = io::read_file("~/Documents/file.txt");
//write a string to the file
io::write_file("/",SteamString);
//read file into vector of chars
var charVec = io::read_file_binary("~/Documents/file2.txt");
//write a vector of chars to a file
io::write_file_binary("/",md5checkSum);
\end{lstlisting}
%----------------------------------------------------------------------------------------
% SECTION Memory Management