I want to use the value of a flag imported from a datatool database (stored in an external .csv file) to enable (or disable) a beamer frame.
The .csv file is of the form:
\begin{filecontents*}{test.csv}
test enable
test1 ok
test2 ok
test3 ok
\end{filecontents*}
Imported into a datatool database :
\DTLloaddb{test}{test.csv}
My command:
\newcommand{\frameIsEnabled}[1]{\ifstrequal{#1}{ok}{1}{0}}
I'm trying to use the \frameIsEnabled command to enable the frame fetching the database value:
\begin{frame}<presentation: \frameIsEnabled{\DTLfetch{test}{test1}{enable}}>
But latex is not happy. I suppose there is something wrong related to the format of the fetched value \DTLfetch{test}{test1}{enable}.
If I display it (i.e. in a table or text) it returns zero (i.e. the comparison with the string "ok" returns false).
Here's a minimal example to reproduce my problem.
Example 1, to verify the comparison of the "enable" flag with the string "ok":
\documentclass[6pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\mode<presentation>{\usetheme{Malmoe}}
\usepackage{datatool}
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
\end{filecontents*}
\newcommand{\frameIsEnabled}[1]{\ifstrequal{#1}{ok}{1}{0}}
\DTLloaddb[headers={testName, enable}]{testList}{test.csv}
\title{My Presentation}
\begin{document}
\begin{frame}<presentation:1>
Test1 enable flag is "\DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns \frameIsEnabled{\DTLfetch{testList}{testName}{test1}{enable}}.
\end{frame}
\end{document}
Within this code, the \frameIsEnabled command will return 0, while the desired output is 1
Example 2, using the fetched value from the database to enable the frame:
\documentclass[6pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\mode<presentation>{\usetheme{Malmoe}}
\usepackage{datatool}
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
\end{filecontents*}
\newcommand{\frameIsEnabled}[1]{\ifstrequal{#1}{ok}{1}{0}}
\DTLloaddb[headers={testName, enable}]{testList}{test.csv}
\title{My Presentation}
\begin{document}
\begin{frame}<presentation:\frameIsEnabled{\DTLfetch{testList}{testName}{test1}{enable}}>
Test1 enable flag is "\DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns \frameIsEnabled{\DTLfetch{testList}{testName}{test1}{enable}}.
\end{frame}
\end{document}
This code will throw the error:
Illegal parameter number in definition of \beamer@@@temp. \end{frame}