ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Problem with expansion tables (macros with variable numbers of paramaters)
@ 2010-11-24  1:04 Jaroslav Hajtmar
  0 siblings, 0 replies; only message in thread
From: Jaroslav Hajtmar @ 2010-11-24  1:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello ConTeXist...

I  work on my first module (t-scancsv) which allows to process external 
CSV files.
Now I have a problem with the processing of tables that require 
expansion line data.
Unable to discover why my macro is not capable of handling the expanded 
rows.
It seems to me that the macros with variable number of parameters work 
differently from the macros with a fixed number of parameters.

I attach a minimal example of what problems occur in the processing of 
expanded lines. I need to write a macro \doloopaction with a variable 
number of parameters that would work as well as macro \doloopfromto, 
which has 3 fixed parameters. In addition, I attach a demonstration of 
the failing macro \DOLOOPFROMTO (variable number of parameters), but 
seems to me the same as the macro \doloopfromto.
Someone help me find out what the problem is??
Thanx Jaroslav

Here is my example:




\def\FirstName{\recurselevel. MyFirstName}
\def\Surname{\recurselevel. MySurname}
\def\Id{\recurselevel. MyId}

\def\lineaction{\expanded{\bTR\bTD \Id \eTD\bTD \FirstName \eTD\bTD 
\Surname \eTD\eTR}}
\def\tab{\bTR\bTD \Id \eTD\bTD \FirstName \eTD\bTD \Surname \eTD\eTR}
\def\xtab{\expanded{\bTR\bTD \Id \eTD\bTD \FirstName \eTD\bTD \Surname 
\eTD\eTR}}

\def\bT{\bTABLE\bTR\bTD ID\eTD\bTD FirstName\eTD\bTD Surname\eTD\eTR}
\def\eT{\eTABLE}


\def\doloopfromto#1#2#3{%
          \dostepwiserecurse{#1}{#2}{1}{#3}
}%



\def\doloopaction{\dotriplegroupempty\doloopAction}

\def\doloopAction#1#2#3{%
   \doifelsenothing{#1}
      {\doloopfromto{1}{10}{\lineaction}%0 par.,
      }
      {\doifelsenothing{#2}
     {\doloopfromto{1}{10}{#1}% 1 par
         }
      {\doifelsenothing{#3}
      {\doloopfromto{1}{#2}{#1}%2 par
   }
      {\doloopfromto{#2}{#3}{#1}%3 par
      }}}
}



\def\DOLOOPFROMTO{\dotriplegroupempty\DOLOOPFROMTOAction}

\def\DOLOOPFROMTOAction#1#2#3{%
   \doifelsenothing{#1}
      {%\doloopfromto{1}{10}{\lineaction}%0 par.,
      \dostepwiserecurse{1}{10}{1}{\lineaction}
      }
      {\doifelsenothing{#2}
     {%\doloopfromto{1}{10}{#1}% 1 par
         \dostepwiserecurse{1}{10}{1}{#1}
         }
      {\doifelsenothing{#3}
      {%\doloopfromto{1}{#2}{#1}%2 par
   \dostepwiserecurse{1}{#2}{1}{#1}
     }
      {%\doloopfromto{#2}{#3}{#1}%3 par
      \dostepwiserecurse{#2}{#3}{1}{#1}
      }}}
}





\starttext

1.  OK, WITHOUT EXPANSION is working as expected

\bT
\doloopfromto{1}{3}{\tab}
\eT


2. OK, with expansion is working as expected

\bT
\doloopfromto{1}{5}{\xtab}
\eT

3. OK, with expansion is working as expected

\bT
\doloopfromto{1}{5}{\lineaction}
\eT


4. OK, with expansion (lineaction macro) is working as expected

\bT
\doloopaction
\eT


5. OK, WITHOUT EXPANSION is working as expected

\bT
\doloopaction{\tab}
\eT


6. OK, WITHOUT EXPANSION is working as expected

\bT
\doloopaction{\tab}{3}
\eT



8. OK, WITHOUT EXPANSION is working as expected

\bT
\doloopaction{\tab}{3}{5}
\eT



9. ERROR, WITH EXPANSION is not working (unlike examples 2, 3, 4)

\bT
%\doloopaction{\xtab}
\eT


10. ERROR, WITH EXPANSION is not working (unlike examples 2, 3, 4)

\bT
%\doloopaction{\xtab}{3}
\eT



11. ERROR, WITH EXPANSION is not working (unlike examples 2, 3, 4)

\bT
%\doloopaction{\xtab}{3}{5}
\eT




12.  OK, WITH EXPANSION (default lineaction) is working as expected

\bT
\DOLOOPFROMTO
\eT


13. OK, WITHOUT expansion, but is working as expected

\bT
\DOLOOPFROMTO{\tab}
\eT



14.  ERROR, WITH EXPANSION is not working (unlike examples 2, 3, 4)

\bT
%\DOLOOPFROMTO{\xtab}
\eT


15.  ERROR, WITH EXPANSION is not working (unlike examples 2, 3, 4)

\bT
%\DOLOOPFROMTO{\lineaction}{4}
\eT


16.  ERROR, WITH EXPANSION is not working (unlike examples 2, 3, 4)

\bT
%\DOLOOPFROMTO{\lineaction}{4}{6}
\eT




\stoptext


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-11-24  1:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24  1:04 Problem with expansion tables (macros with variable numbers of paramaters) Jaroslav Hajtmar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).