ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* MetaPost + format("%g",n)
@ 2010-03-08  3:46 Troy Henderson
  2010-03-08  4:05 ` Troy Henderson
  0 siblings, 1 reply; 9+ messages in thread
From: Troy Henderson @ 2010-03-08  3:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

This code compiles fine with plain MetaPost.

input graph;
beginfig(0);
   draw begingraph(1in,1in);
      setrange((0,0),(1,1));
      for n=auto.x:
         show format("%g",n);
      endfor;
   endgraph;
endfig;
end

However, this "ConTeXt translated" version errors in MKIV

\usemodule[graph]
\ctxlua{metapost.showlog=true}
\startMPpage
   draw begingraph(1in,1in);
      setrange((0,0),(1,1));
      for n=auto.x:
         show format("%g",n);
      endfor;
   endgraph;
\stopMPpage

See foo.log (attached).

Thoughts?

Troy

[-- Attachment #2: foo.log --]
[-- Type: text/plain, Size: 6622 bytes --]

(foo.tex

ConTeXt  ver: 2010.03.02 12:34 MKIV  fmt: 2010.3.6  int: english/english

system          : cont-new loaded
(/opt/context-minimals/tex/texmf-context/tex/context/base/cont-new.tex
systems         : beware: some patches loaded from cont-new.tex
(/opt/context-minimals/tex/texmf-context/tex/context/base/cont-new.mkiv))
system          : cont-fil loaded
(/opt/context-minimals/tex/texmf-context/tex/context/base/cont-fil.tex
loading         : ConTeXt File Synonyms
)
system          : cont-sys loaded
(/opt/context-minimals/tex/texmf-local/tex/context/user/cont-sys.tex (/opt/context-minimals/tex/texmf-context/tex/context/base/type-def.mkiv) (/opt/context-minimals/tex/texmf-context/tex/context/base/type-lua.tex) (/opt/context-minimals/tex/texmf-context/tex/context/base/type-siz.tex (/opt/context-minimals/tex/texmf-context/tex/context/base/type-siz.mkiv)) (/opt/context-minimals/tex/texmf-context/tex/context/base/type-otf.tex (/opt/context-minimals/tex/texmf-context/tex/context/base/type-otf.mkiv)))
system          : foo.top loaded
%
%	begin of optionfile
%
%	% runtime options files (command line driven)
%	\unprotect
%	% special commands, mostly for the ctx development team
%	% feedback and basic job control
%	% handy for special styles
%	\startluacode
%	document = document or { }
%	document.arguments={
%	}
%	document.files={
%	 "foo.tex",
%	}
%	\stopluacode
%	% process info
%	\setupsystem[inputfile=foo.tex]
%	\setupsystem[\c!n=1,\c!m=1]
%	% modes
%	% options (not that important)
%	\startsetups *runtime:options
%	\setupoutput[pdftex]
%	\stopsetups
%	% styles and modules
%	\startsetups *runtime:modules
%	\stopsetups
%	% done
%	\protect \endinput
%
%	end of optionfile
%
(foo.top)
fonts           : preloading latin modern fonts
(/opt/context-minimals/tex/texmf-local/tex/context/luc/type-luc.tex)
bodyfont        : 12pt rm is loaded
language        : language en is active
(/opt/context-minimals/tex/texmf-context/tex/context/base/m-graph.tex (/opt/context-minimals/tex/texmf-context/tex/context/base/m-graph.mkiv))
system          : module graph loaded
systems         : begin file foo.tex at line 10
systems         : auto \starttext..\stoptext
mplib           : initializing instance 'metafun' using format 'metafun'
mplib           : loading 'metafun.mp' from '/opt/context-minimals/tex/texmf-cache/luatex-cache/context/ccfefc91ec3ed68af1aeed1f470fef4d/formats/cont-en-metafun.mem'
!mplib          : mp log: (/opt/context-minimals/tex/texmf/metapost/base/graph.mp)

!mplib          : mp terminal: ! Incomplete string token has been flushed.
<*> ... n=auto.x: show format("endfor; endgraph; ;
                                                  


!mplib          : mp error: unknown, no error, terminal or log messages
!mplib          : mp terminal: [1]

!mplib          : mp error: unknown, no error, terminal or log messages
!mplib          : mp terminal: 

!mplib          : mp error: unknown, no error, terminal or log messages
!mplib          : mp terminal: 

!mplib          : mp error: unknown, no error, terminal or log messages
!mplib          : mp terminal: (Please type a command or say `end')

!mplib          : mp error: unknown, no error, terminal or log messages
!mplib          : mp terminal: ! Incomplete string token has been flushed.
<*> ... n=auto.x: show format("endfor; endgraph; ;
                                                  


!mplib          : mp error: unknown, no error, terminal or log messages
!mplib          : mp terminal: [1]

!mplib          : mp error: unknown, no error, terminal or log messages
fonts           : resetting map file list
{/opt/context-minimals/tex/texmf-context/fonts/map/pdftex/context/original-empty.map}
fonts           : using map file: original-base
{/opt/context-minimals/tex/texmf-context/fonts/map/pdftex/context/original-base.map}
fonts           : using map file: original-ams-base
{/opt/context-minimals/tex/texmf-context/fonts/map/pdftex/context/original-ams-base.map}
fonts           : using map file: original-ams-euler
{/opt/context-minimals/tex/texmf-context/fonts/map/pdftex/context/original-ams-euler.map}
fonts           : using map file: original-public-lm
{/opt/context-minimals/tex/texmf-context/fonts/map/pdftex/context/original-public-lm.map}
fonts           : using map file: lm-math
{/opt/context-minimals/tex/texmf/fonts/map/dvips/lm/lm-math.map}
fonts           : using map file: lm-rm
{/opt/context-minimals/tex/texmf/fonts/map/dvips/lm/lm-rm.map}
!pages          : flushing realpage 1, userpage 1, subpage 1
systems         : end file foo.tex at line 10
 )
mkiv lua stats : used config path          - /opt/context-minimals/tex/texmf/web2c/texmf.cnf
mkiv lua stats : used cache path           - /opt/context-minimals/tex/texmf-cache
mkiv lua stats : input load time           - 0.046 seconds
mkiv lua stats : stored bytecode data      - 204 modules, 49 tables, 253 chunks
mkiv lua stats : loaded tex modules        - 1 requested, 1 found (*-graph), 0 missing
mkiv lua stats : node list callback tasks  - 6 unique task lists, 4 instances (re)created, 273 calls
mkiv lua stats : cleaned up reserved nodes - 24 nodes, 9 lists of 1409
mkiv lua stats : node memory usage         - 19 glue_spec, 1 dir
mkiv lua stats : used backend              - pdf (backend for directly generating pdf output)
mkiv lua stats : loaded patterns           - en:us:pat:exc:2
mkiv lua stats : startup time              - 0.698 seconds including runtime option file processing
mkiv lua stats : callbacks                 - direct: 404, indirect: 4171, total: 4575
mkiv lua stats : lxml preparation time     - 0.000 seconds, 0 nodes, 15 lpath calls, 0 cached calls
mkiv lua stats : result saved in file      - foo.pdf
mkiv lua stats : loaded fonts              - 32 files: lmmono12-regular.otf lmmono8-regular.otf lmmono9-regular.otf lmroman12-bold.otf lmroman12-regular.otf lmroman7-bold.otf lmroman7-regular.otf lmroman9-bold.otf lmroman9-regular.otf lmsans12-regular.otf lmsans8-regular.otf lmsans9-regular.otf eufb10.tfm eufb7.tfm eufm10.tfm eufm7.tfm msam10.tfm msam7.tfm msbm10.tfm msbm7.tfm lmex10.tfm lmmi12.tfm lmmi7.tfm lmmi9.tfm lmmib10.tfm lmmib7.tfm lmsy10.tfm lmsy7.tfm lmsy9.tfm rm-lmr12.tfm rm-lmr7.tfm rm-lmr9.tfm
mkiv lua stats : fonts load time           - 0.363 seconds 
mkiv lua stats : luatex banner             - this is luatex, version beta-0.51.0-2010030618 (rev 3452)
mkiv lua stats : control sequences         - 30066 of 165536
mkiv lua stats : current memory usage      - 41 MB (ctx: 42 MB)
mkiv lua stats : runtime                   - 1.419 seconds, 0 processed pages, 1 shipped pages, 0.705 pages/second


[-- Attachment #3: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
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] 9+ messages in thread

* Re: MetaPost + format("%g",n)
  2010-03-08  3:46 MetaPost + format("%g",n) Troy Henderson
@ 2010-03-08  4:05 ` Troy Henderson
  2010-03-08  4:33   ` Troy Henderson
  0 siblings, 1 reply; 9+ messages in thread
From: Troy Henderson @ 2010-03-08  4:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

For the record, I'm not actually trying to "show" the picture that is
returned by the format() function, but instead I want to assign the
value of this picture to a variable, and it is erroring with that as
well.

Troy
___________________________________________________________________________________
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] 9+ messages in thread

* Re: MetaPost + format("%g",n)
  2010-03-08  4:05 ` Troy Henderson
@ 2010-03-08  4:33   ` Troy Henderson
  2010-03-08  5:31     ` Troy Henderson
  0 siblings, 1 reply; 9+ messages in thread
From: Troy Henderson @ 2010-03-08  4:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Sorry for the flood.  After some digging around it seems like the %
should now be replaced by @.  That is, I should use

format("@g",n)

Troy
___________________________________________________________________________________
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] 9+ messages in thread

* Re: MetaPost + format("%g",n)
  2010-03-08  4:33   ` Troy Henderson
@ 2010-03-08  5:31     ` Troy Henderson
  2010-03-08  7:58       ` MetaPost sarith (graph) package Taco Hoekwater
  0 siblings, 1 reply; 9+ messages in thread
From: Troy Henderson @ 2010-03-08  5:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Is the sarith package usable in MKIV?  For example, I would like to
get the numerical (not string) values of auto.x and auto.y from the
graph package.  I expect the following example to work, but it does
not (even if I "input sarith") with MPinclusions.

\usemodule[graph]
\ctxlua{metapost.showlog=true}
\startMPpage
  draw begingraph(1in,1in);
     setrange((0,0),(1,1));
     for n=auto.x:
        show Scvnum n; % This is the line that is failing
     endfor;
  endgraph;
\stopMPpage
___________________________________________________________________________________
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] 9+ messages in thread

* Re: MetaPost sarith (graph) package
  2010-03-08  5:31     ` Troy Henderson
@ 2010-03-08  7:58       ` Taco Hoekwater
  2010-03-08  8:18         ` Wolfgang Schuster
  0 siblings, 1 reply; 9+ messages in thread
From: Taco Hoekwater @ 2010-03-08  7:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Troy Henderson wrote:
> Is the sarith package usable in MKIV?  For example, I would like to
> get the numerical (not string) values of auto.x and auto.y from the
> graph package.  I expect the following example to work, but it does
> not (even if I "input sarith") with MPinclusions.

This works:

\startMPinclusions
input graph;
input sarith;
\stopMPinclusions

Apparently, an explicit input graph is needed as well. I have no idea
why though, as there is an \startMPinclusions inside m-graph.mkiv too.

Best wishes,
Taco



___________________________________________________________________________________
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] 9+ messages in thread

* Re: MetaPost sarith (graph) package
  2010-03-08  7:58       ` MetaPost sarith (graph) package Taco Hoekwater
@ 2010-03-08  8:18         ` Wolfgang Schuster
  2010-03-08 14:28           ` MPinclusions/MetaPost " Alan BRASLAU
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2010-03-08  8:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 08.03.10 08:58, schrieb Taco Hoekwater:
> Troy Henderson wrote:
>> Is the sarith package usable in MKIV?  For example, I would like to
>> get the numerical (not string) values of auto.x and auto.y from the
>> graph package.  I expect the following example to work, but it does
>> not (even if I "input sarith") with MPinclusions.
>
> This works:
>
> \startMPinclusions
> input graph;
> input sarith;
> \stopMPinclusions
>
> Apparently, an explicit input graph is needed as well. I have no idea
> why though, as there is an \startMPinclusions inside m-graph.mkiv too.

\startMPinclusions[+]
input sarith;
\stopMPinclusions

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: MPinclusions/MetaPost sarith (graph) package
  2010-03-08  8:18         ` Wolfgang Schuster
@ 2010-03-08 14:28           ` Alan BRASLAU
  2010-03-08 14:35             ` luigi scarso
  0 siblings, 1 reply; 9+ messages in thread
From: Alan BRASLAU @ 2010-03-08 14:28 UTC (permalink / raw)
  To: ntg-context

On Monday 08 March 2010 09:18:38 Wolfgang Schuster wrote:
> 
> \startMPinclusions[+]
> input sarith;
> \stopMPinclusions
> 

This probably explains other problems that I had experienced
concerning \startMPinclusions\stopMPinclusions...
Indeed, as metapost is processed in one run under mkIV,
I had gotten around such problems by simply putting certain metapost
definitions in an early instance of \startMPcode\stopMPcode.

Perhaps the [+] option could/should be by default for MPinclusions
with some other option syntax allowing one to reinitialize
the MPinclusions. Or maybe not...
In any case, we need to document this more clearly.

Concerning the graph package:
1) Should it use \startMPinclusions[+] so as not to erase
other MPinclusions?
2) Is there a penalty/overhead in including sarith by default
in the graph package?
3) Will metapost be able to better handle arithmetic soon,
and/or can someone suggest a better way of using lua along
with metapost graph? (Currently I externally use "awk"
via \immediate\write18 to manipulate data.)

Alan
___________________________________________________________________________________
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] 9+ messages in thread

* Re: MPinclusions/MetaPost sarith (graph) package
  2010-03-08 14:28           ` MPinclusions/MetaPost " Alan BRASLAU
@ 2010-03-08 14:35             ` luigi scarso
  2010-03-08 14:55               ` data manipulation (was sarith) Alan BRASLAU
  0 siblings, 1 reply; 9+ messages in thread
From: luigi scarso @ 2010-03-08 14:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Mar 8, 2010 at 3:28 PM, Alan BRASLAU <alan.braslau@cea.fr> wrote:

> (Currently I externally use "awk"
> via \immediate\write18 to manipulate data.)
In mkiv you should be able to manipulate your data with lua & lpeg.
You gain in portability -- no need of an external awk

-- 
luigi
___________________________________________________________________________________
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] 9+ messages in thread

* Re: data manipulation (was sarith)
  2010-03-08 14:35             ` luigi scarso
@ 2010-03-08 14:55               ` Alan BRASLAU
  0 siblings, 0 replies; 9+ messages in thread
From: Alan BRASLAU @ 2010-03-08 14:55 UTC (permalink / raw)
  To: ntg-context

On Monday 08 March 2010 15:35:14 luigi scarso wrote:
> On Mon, Mar 8, 2010 at 3:28 PM, Alan BRASLAU <alan.braslau@cea.fr> wrote:
> > (Currently I externally use "awk"
> > via \immediate\write18 to manipulate data.)
> 
> In mkiv you should be able to manipulate your data with lua & lpeg.
> You gain in portability -- no need of an external awk
> 

Yes, another language to learn...  (after all, I *like* awk)

Can you indicate a good starting point?
(perhaps this message should be filed under the thread on documentation...)

Alan
___________________________________________________________________________________
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] 9+ messages in thread

end of thread, other threads:[~2010-03-08 14:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-08  3:46 MetaPost + format("%g",n) Troy Henderson
2010-03-08  4:05 ` Troy Henderson
2010-03-08  4:33   ` Troy Henderson
2010-03-08  5:31     ` Troy Henderson
2010-03-08  7:58       ` MetaPost sarith (graph) package Taco Hoekwater
2010-03-08  8:18         ` Wolfgang Schuster
2010-03-08 14:28           ` MPinclusions/MetaPost " Alan BRASLAU
2010-03-08 14:35             ` luigi scarso
2010-03-08 14:55               ` data manipulation (was sarith) Alan BRASLAU

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