1

I need the value of a variable, set in ifeqcase, outside of ifeqcase. For example this code doesn't work

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{geometry}
\usepackage{calculator,calculus}
\usepackage{multido}
\usepackage{xstring}
\usepackage[fontsize=22pt]{scrextend}
\setmainfont{Latin Modern Sans Quotation}
\geometry{papersize{30cm,19.35cm},left=1cm,right=1cm,top=1cm,bottom=1cm}
\pagestyle{empty}
\newcommand{\valeurcal}[2]{
\SUBTRACT{1}{\ra}{\partiell}
\MULTIPLY{\partiell}{#1}{\partielll}
\MULTIPLY{\ra}{#2}{\partiell}
\ADD{\partiell}{\partielll}{\leresultat}
}

\begin{document}
\multido{\ra=0.0+0.2}{1}{
\valeurcal{0}{5}
\ROUND[0]{\leresultat}{\coupe}
\IfEqCase{\coupe}{%
{1}{ \COPY{5}{\nouvcoupe}}% test with calculator
{2}{  \def\nouvcoupe{6}}}% test with def, edef and gdef (thank for the answer)
value of nouvcoupe : \nouvcoupe}
\end{document}

give me : Undefined control sequence. (compiled with xelatex)

The probleme seems to come with \valeurcal{0}{5}. If I replace \valeurcal{0}{5} by \COPY{2}{\leresultat} I can compile it (but it don't do the job)!

\valeurcal{0}{5} calculate 0*(1-\ra)+5*\ra where \ra What do you advise to me? Thank you in advance.

2 Answers2

1

use

\gdef\nouvcoupe{6}

global definition

0

OK [\def\nouvcoupe{6}] was missing

\IfEqCase{\coupe}{%
{1}{ \COPY{5}{\nouvcoupe}}% test with calculator
{2}{  \def\nouvcoupe{6}}}[\def\nouvcoupe{6}]

is oK

  • What about if I need to use multiple conditions/variables for the same case, for example CASE1: if a=1 and /orb=2 : then do this and so on.Identifying multiple variables in the same case – Silva Feb 20 '20 at 21:09