I am trying to create a new environment and use it as a customized array (with many changes in the code given). So I need to read the \BODY of the \NewEnviron and read it line by line. I don't care if I have to finish the lines with \\ or with empty line or whatever. But I have to read them one by one and I don't know how many lines there are before using the environment.
I tried this:
\documentclass{article}
\usepackage{environ}
\usepackage{xstring}
\makeatletter
\long\def\findLength#1{\StrLen{#1}[\temp] The length of ``#1'' is \temp\\}
\NewEnviron{Graph}{\findLength{\BODY}}{}
\makeatother
\begin{document}
\begin{Graph}
test line 1
test line 2
\end{Graph}
\end{document}
But uses all the \BODY and not line by line.
Also If I add a linebreak the #1 of \StrLen is no more a string (contains linebreak and gives errors).
I have finally manage to take the first line in my new environment using the code of @Bruno Le Floch from here but I don't really understand that code and I don't know what to read to understand it and change it for taking all the arguments. Also I can not yet add \ in the end of the rows to show where the line of the array ends... Here is what I have now:
\documentclass{article}
\usepackage{environ}% defines `NewEnviron`
\usepackage{xstring}
\makeatletter
\newcommand*{\newlinecommand}[2]{%
\newcommand*{#1}{%
\begingroup%
\escapechar=`\\%
\catcode\endlinechar=\active%
\csname\string#1\endcsname%
}%
\begingroup%
\escapechar=`\\%
\lccode`\~=\endlinechar%
\lowercase{%
\expandafter\endgroup
\expandafter\def\csname\string#1\endcsname##1~%
}{\endgroup#2\par\space}%
}
\makeatother
\makeatletter
\newlinecommand{\findLengthOfRow}{\StrLen{#1}[\temp] The length of ``#1'' is \temp}
\makeatother
\makeatletter
\long\def\findLength#1{\findLengthOfRow{#1}}
\newenvironment{Graph}{\findLength}{}
\makeatother
\begin{document}
\begin{Graph}
test line 1
test line 2
test line 3
\end{Graph}
\end{document}
Any help will be appreciated. The result I want is to take as arguments the rows in the environment. (I don't now how many rows will have the array. So don't give specific number of arguments in the newenvironment).


