ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* hysteresis with content in blocks (one strike and you can be out forever)
@ 2019-02-06 15:53 Sanjoy Mahajan
  2019-02-06 16:35 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Sanjoy Mahajan @ 2019-02-06 15:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Apologies for the cutesy subtitle.  In plainer English, the information
saved in the .tuc file can make it so that a valid ConTeXt file doesn't
compile merely because of what it contained when it was compiled before.

Here is a MIE (minimal illustrative example), on Linux amd64, 2019.01.28 beta:

1. Make the following file:

========== file: testhysteresis.tex ===============
\defineblock[foo]

\starttext

\def\abc{20}
\beginfoo
Use \abc
\endfoo

\useblocks[foo]

\stoptext
========== stop: testhysteresis.tex ===============

2. Compile it with "context --nonstopmode testhysteresis.tex" (which
   will work fine).

3. Modify it so that it doesn't define or use \abc (and so that it is
   still valid):

========== file: testhysteresis.tex ===============
\defineblock[foo]

\starttext

\beginfoo
Use
\endfoo

\useblocks[foo]

\stoptext
========== stop: testhysteresis.tex ===============

4. Without deleting testhysteresis.tuc, recompile with "context
   --nonstopmode testhysteresis.tex".  This run fails with the fatal error:

     tex error       > tex error on line 1 in file virtual://block.foo.1: ! Undefined control sequence

     l.1 Use \abc

   The cause seems to be that testhysteresis.tuc contains (from the run
   it step 2 above):

     utilitydata.structures.blocks.collected={
      {
       ["data"]="Use \\abc",
       ["index"]=1,
       ["metadata"]=3,
       ["references"]={
        ["section"]=0,
       },
      },
     }

5. Delete testhysteresis.tuc.

6. Now "context --nonstopmode testhysteresis.tex" works fine.

One workaround is always to delete the .tuc file before running context.
But that approach seems like overkill (although in my scripts that I use
for running expeirments with blocks etc., I take this approach), and
maybe there is a simpler way.

Best,
-Sanjoy
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: hysteresis with content in blocks (one strike and you can be out forever)
  2019-02-06 15:53 hysteresis with content in blocks (one strike and you can be out forever) Sanjoy Mahajan
@ 2019-02-06 16:35 ` Wolfgang Schuster
  2019-02-06 17:28   ` Sanjoy Mahajan
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2019-02-06 16:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Sanjoy Mahajan

Sanjoy Mahajan schrieb am 06.02.19 um 16:53:
> Apologies for the cutesy subtitle.  In plainer English, the information
> saved in the .tuc file can make it so that a valid ConTeXt file doesn't
> compile merely because of what it contained when it was compiled before.
> 
> Here is a MIE (minimal illustrative example), on Linux amd64, 2019.01.28 beta:
> 
> 1. Make the following file:
> 
> ========== file: testhysteresis.tex ===============
> \defineblock[foo]
> 
> \starttext
> 
> \def\abc{20}
> \beginfoo
> Use \abc
> \endfoo
> 
> \useblocks[foo]
> 
> \stoptext
> ========== stop: testhysteresis.tex ===============
> 
> 2. Compile it with "context --nonstopmode testhysteresis.tex" (which
>     will work fine).
> 
> 3. Modify it so that it doesn't define or use \abc (and so that it is
>     still valid):
> 
> ========== file: testhysteresis.tex ===============
> \defineblock[foo]
> 
> \starttext
> 
> \beginfoo
> Use
> \endfoo
> 
> \useblocks[foo]
> 
> \stoptext
> ========== stop: testhysteresis.tex ===============
> 
> 4. Without deleting testhysteresis.tuc, recompile with "context
>     --nonstopmode testhysteresis.tex".  This run fails with the fatal error:
> 
>       tex error       > tex error on line 1 in file virtual://block.foo.1: ! Undefined control sequence
> 
>       l.1 Use \abc
> 
>     The cause seems to be that testhysteresis.tuc contains (from the run
>     it step 2 above):
> 
>       utilitydata.structures.blocks.collected={
>        {
>         ["data"]="Use \\abc",
>         ["index"]=1,
>         ["metadata"]=3,
>         ["references"]={
>          ["section"]=0,
>         },
>        },
>       }
> 
> 5. Delete testhysteresis.tuc.
> 
> 6. Now "context --nonstopmode testhysteresis.tex" works fine.
> 
> One workaround is always to delete the .tuc file before running context.
> But that approach seems like overkill (although in my scripts that I use
> for running expeirments with blocks etc., I take this approach), and
> maybe there is a simpler way.

You can set dimensions with the measure system

%\definemeasure [TestValue] [20pt]

\starttext
\measure{TestValue}
\stoptext

and other values with \setvariables

%\setvariables [test] [abc=20]

\starttext

\getvariable{test}{abc}

\getvariabledefault{test}{abc}{10}

\stoptext

Both systems work even with unset values.

Wolfgang
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: hysteresis with content in blocks (one strike and you can be out forever)
  2019-02-06 16:35 ` Wolfgang Schuster
@ 2019-02-06 17:28   ` Sanjoy Mahajan
  0 siblings, 0 replies; 3+ messages in thread
From: Sanjoy Mahajan @ 2019-02-06 17:28 UTC (permalink / raw)
  To: Wolfgang Schuster, mailing list for ConTeXt users

> You can set dimensions with the measure system
>
> %\definemeasure [TestValue] [20pt]
>
> \starttext
> \measure{TestValue}
> \stoptext
>
> and other values with \setvariables
>
> %\setvariables [test] [abc=20]

Probably the .tuc hystersis can jump up and bite one in the rear end in
other ways.  But \definemeasure and \setvariables do solve the issue in
my example.  They were also new to me and should prove useful for my
style files.  (The amount of ConTeXt still to learn is very large...)

-Sanjoy
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-06 17:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 15:53 hysteresis with content in blocks (one strike and you can be out forever) Sanjoy Mahajan
2019-02-06 16:35 ` Wolfgang Schuster
2019-02-06 17:28   ` Sanjoy Mahajan

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).