ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Problem with expansion tables (macros with variable numbers of paramaters)
Date: Wed, 24 Nov 2010 02:04:22 +0100	[thread overview]
Message-ID: <4CEC6496.1080002@gyza.cz> (raw)

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
___________________________________________________________________________________


                 reply	other threads:[~2010-11-24  1:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CEC6496.1080002@gyza.cz \
    --to=hajtmar@gyza.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).