I have come upon a problem I'd like to solve but unable to by myself. My intention is to create a library of components with different parameters and do calculations with FPeval. Here is the code:
\documentclass{article}
\usepackage{fp}% http://ctan.org/pkg/fp
\usepackage{xstring}% http://ctan.org/pkg/xstring
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{color}
%STRUCT
\newcommand \Rmin[2]{\ensuremath{\FPeval{\result}{round(#1-(#1*#2/100),2)}\result}}
\newcommand \Rmax[2]{\ensuremath{\FPeval{\result}{round(#1+(#1*#2/100),2)}\result}}
\newcommand\defResCMtype[2]{%defined VARIOUS types
\expandafter\newcommand\csname TOL#1\endcsname{#2}
}
\newcommand\defResCM[3]{%
\expandafter\newcommand\csname value#1\endcsname{#2}
\expandafter\newcommand\csname #1min\endcsname{
\StrDel{#3}{ }[\tmp]% remove spaces and store the string in \tmp
\IfEqCase{\tmp}{{typeX}{\Rmin{#2}{\TOLtypeX}}
}%
[{\color{red}XXXXXX}] %ERROR
}
\expandafter\newcommand\csname #1max\endcsname{
\StrDel{#3}{ }[\tmp]% remove spaces and store the string in \tmp
\IfEqCase{\tmp}{{typeX}{\Rmax{#2}{\TOLtypeX}}
}%
[{\color{red}XXXXXX}] %ERROR
}
}
%LIB
\defResCMtype{typeX}{5}
\defResCM{compX}{100}{typeX}
%CALC
\newcommand \calc[2]{\ensuremath{\FPeval{\result}{round(#1,#2)}\result}}
\newcommand \testcalcA{\ensuremath{\calc{(105 / 95)}{2}}} %calculated with numbers
\newcommand \testcalcB{\ensuremath{\calc{((\compXmax)/(\compXmin))}{2}}} %calculated with macros -> NOT WORKING
\begin{document}
test = \valuecompX \\
test2= \compXmax \\
test3= \compXmin \\
A = \testcalcA \\ %-> WORKING
%B = \testcalcB \\ %-> NOT WORKING
\end{document}
If I manually enter the numbers created from the test2 & test3 then FPeval calculates the equation A, however, if I want to pass these values automatically as (\compXmax) & (\compXmin) or even comXmax & comXmin in
\newcommand \testcalcB{\ensuremath{\calc{((\compXmax)/(\compXmin))}{2}}}
I get an error ! Use of \@newline doesn't match its definition.\kernel@ifnextchar ...rved@d =#1\def \reserved@a {#2}\def \reserved@b {#3}\f... B = \testcalcB.
Manually inserting numbers between calculations in a document is error prone which I would very much like to avoid, since updating a parameter directly in library would need an update to the whole document where these parameters are used.

\compXmaxand\compXmin, and your string operations are not expandable. Can you explain what the above implements so we can avoid having to work that out and can make useful code suggestions? – Joseph Wright Jan 09 '15 at 08:58\defResCM{compX}{100}{typeX}, set its value and divide it by type. From these parameters calculate the minimum, maximum value and use these in other equations. Therefore avoid re-typing minmax values which is rather error prone when there are hundreads or more components used. That is why I would like to have a separate file with stored components. Tried the code below from @Steven B. Segletes and it works, but I'm not fond of a library in the document. – MAAG Jan 09 '15 at 13:05\AtBeginDocument{\defResCMtype{typeX}{5}\defResCM{compX}{100}{typeX}}, which works fine with the present construct. – Steven B. Segletes Jan 12 '15 at 03:09