# Global variable to macros

I have a eskdi.sty style file where I define two command:

\newcommand{\gostorganizatia}[2]{%
\ifnum #1 = 1% 1 - text; 2 - logo
\gdef\gostorganizatiaopt{text}%%
\def\gostorganizatiatext#2{\gdef\@gostorganizatiatext{#2}\relax}%
\else%
\gdef\gostorganizatiaopt{logo}%
\def\gostorganizatialogo#2{\gdef\@gostorganizatialogo{#2}\relax}%
\fi%
}


And in another ESKD_frames.sty style file:

\ifx \gostorganizatiaopt text%
\spformedboxmm{135}{20}{185}{4.0}{s}{\@gostorganizatiatext}%
\else%
\spformedboxmm{150}{16}{170}{4.0}{s}{\includegraphics*[keepaspectratio=true, height=10mm]{\@gostorganizatialogo}}%
\fi%


Macro spformedboxmm draw #6 argument between x1-x2 and y1,y2 with parameter s.

Usage in a title.tex:

\gostorganizatia{1}{some text}% for drawing text


or to draw float figure

\gostorganizatia{2}{./path_to_logo.jpg}


What is the best way to define global variable to use it in a different *.sty files?

Update:

In a main.log there are few error:

! Undefined control sequence. ...age LaTeX Error: File \@gostorganizatialogo ' not found.** and **! LaTeX Error: File' not found.

It seems to me that \gostorganizatiaopt does not work.

• your question is not very clear, what do you need to define? After \newcommand{\gostorganizatia}[2] the macro takes two arguments so the use should be \gostorganizatia{1}{some text} not \gostorganizatia{1, some text} note also you are missing % from ends of lines in the definition \gdef\@gostorganizatiaoption{1} should be \gdef\@gostorganizatiaoption{1}% and same for {2} – David Carlisle May 31 '16 at 11:53
• Ok, I'll check it, maybe it's my syntax error – Ulrich Von Rekkenin May 31 '16 at 12:14
• Also, asking a question of the form "What is the best way..." requests subjective input as there may be no best way, or different people think their own solution is best. – Werner May 31 '16 at 14:30

You think that

\ifx \gostorganizatiaopt text%


test whether \gostorganizatiaopt is being compared to text. However, it's actually being compared to t, and it will never be true in your case. If you want a text-comparison, use the e-TeX \pdfstrcmp{<strA>}{<strB>} which returns 0 if <strA> = <strB>:

\ifnum\pdfstrcmp{\gostorganizatiaopt}{text}=0
% TRUE <text>
\else
% FALSE <logo>
\fi


A counter is the best way for me.

In the eskdi.sty file declare macro

\newcounter{gostorgcounter}% 0=text; 1=logo
\newcommand{\gostorganizatia}[2]{%
%
\setcounter{gostorgcounter}{#1}%
%
\ifnum\thegostorgcounter=0% 0 - text; 1 - logo
\newcommand{\gostorganizatiatext}[1]{#2}
\fi%
%
\ifnum\thegostorgcounter=1%
\newcommand{\gostorganizatialogo}[1]{#2}
\fi%
}%


In a drawing file the follow construction:

\ifnum\thegostorgcounter=0% text mode
\spboxmm{125}{10}{170}{4.0}{lc}{\parbox{70mm}{\centering \gostorganizatiatext{}}}
\fi%
%
\ifnum\thegostorgcounter=1% logo mode
\spformedboxmm{150}{10}{170}{4.0}{c}{\includegraphics[keepaspectratio=true]{\gostorganizatialogo{}}}%
\fi%


Usage \gostorganizatia{0}{some text} for text mode or \gostorganizatia{1}{./path_to_logo.jpg} for image.