\define@key{var}{name}{\def\variable@name{#1}}
\define@key{var}{name label}{\def\variable@namelbl{#1}}
\define@key{var}{value}{\def\variable@value{#1}}
\define@key{var}{label}{\def\variable@label{#1}}
\define@key{var}{ref}{\def\variable@ref{#1}}
\presetkeys{var}{name=,name label=,value=,label=,ref=}{}
\def\variable{\@ifnextchar[\@variable{\@variable[]}}
\def\@variable[#1](#2,#3){
  \setkeys{var}{#1}%
  \ifx\variable@ref\@empty
    \draw (#2,#3) node[draw,minimum width=1.8cm,line width=1pt,minimum height=0.6cm] (\variable@label) {\variable@value};
  \else
    \draw (#2,#3) node[draw,minimum width=1.8cm,line width=1pt,minimum height=0.6cm] (\variable@label) {};
    \draw (\variable@label.center) node[fill,shape=circle,inner sep=0pt,minimum size=2pt] {};
    \draw[dashed,line width=0.6pt,-stealth] (\variable@label.center) -- (\variable@ref);

  \fi
  \ifx\variable@name\@empty
  \else
    \draw (#2,#3) ++(-0.9,0.3) ++(-0.5pt,-0.5pt) node[draw,anchor=south west,minimum width=0.6cm,line width=1pt,minimum height=0.6cm] (\variable@namelbl) {\variable@name};
  \fi
}
