Skip to content
Snippets Groups Projects
Commit dfb8c2f3 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

macroprocessor doc: update for microprocessing functions

parent 7baee731
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
\author{Sébastien Villemot} \author{Sébastien Villemot}
%\pgfdeclareimage[height=0.6cm]{logo}{logo-ofce} %\pgfdeclareimage[height=0.6cm]{logo}{logo-ofce}
\institute{CEPREMAP} \institute{CEPREMAP}
\date{June 6, 2018} \date{July 9, 2018}
\AtBeginSection[] \AtBeginSection[]
{ {
...@@ -95,12 +95,13 @@ ...@@ -95,12 +95,13 @@
\frametitle{Variables} \frametitle{Variables}
\begin{itemize} \begin{itemize}
\item The macro processor has its own list of variables which are different than model variables and MATLAB/Octave variables \item The macro processor has its own list of variables which are different than model variables and MATLAB/Octave variables
\item There are 4 types of macro-variables: \item There are 5 types of macro-variables:
\begin{itemize} \begin{itemize}
\item integer \item integer
\item string (declared between \textit{double} quotes) \item string (declared between \textit{double} quotes)
\item integer array \item integer array
\item string array \item string array
\item string function
\end{itemize} \end{itemize}
\item No boolean type: \item No boolean type:
\begin{itemize} \begin{itemize}
...@@ -157,7 +158,8 @@ ...@@ -157,7 +158,8 @@
The value of a macro-variable can be defined with the \verb+@#define+ directive. The value of a macro-variable can be defined with the \verb+@#define+ directive.
\begin{block}{Syntax} \begin{block}{Syntax}
\verb+@#define +\textit{variable\_name}\verb+ = +\textit{expression} \verb+@#define +\textit{variable\_name}\verb+ = +\textit{expression}\\
\verb+@#define +\textit{function\_name}(\textit{arg1}, [\textit{arg2}, ...])\verb+ = +\textit{string\_expression}
\end{block} \end{block}
\begin{block}{Examples} \begin{block}{Examples}
...@@ -168,6 +170,9 @@ ...@@ -168,6 +170,9 @@
@#define w = [ "US", "EA" ] // String array @#define w = [ "US", "EA" ] // String array
@#define z = 3 + v[2] // Equals 5 @#define z = 3 + v[2] // Equals 5
@#define t = ("US" in w) // Equals 1 (true) @#define t = ("US" in w) // Equals 1 (true)
@#define s = "@{y}" // Equals "US"
@#define f(x) = " + @{x} + @{y}" // A function "f(x)" equal
// to " + @{x} + US"
\end{verbatim} \end{verbatim}
\end{block} \end{block}
\end{frame} \end{frame}
...@@ -179,16 +184,17 @@ ...@@ -179,16 +184,17 @@
\begin{verbatim} \begin{verbatim}
@#define x = [ "B", "C" ] @#define x = [ "B", "C" ]
@#define i = 2 @#define i = 2
@#define f(x) = " + @{x}"
model; model;
A = @{x[i]}; A = @{x[i] + f("D")};
end; end;
\end{verbatim} \end{verbatim}
\end{block} \end{block}
\begin{block}{After macro-processing} \begin{block}{After macro-processing}
\begin{verbatim} \begin{verbatim}
model; model;
A = C; A = C + D;
end; end;
\end{verbatim} \end{verbatim}
\end{block} \end{block}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment