From: Bruce Horrocks <ntg@scorecrow.com>
To: ntg-context mailing list <ntg-context@ntg.nl>
Subject: [NTG-context] Re: Calling C code from ConTeXt LMTX
Date: Mon, 16 Sep 2024 13:06:03 +0100 [thread overview]
Message-ID: <C6E57381-EA47-473D-9138-8C67C71E09F8@scorecrow.com> (raw)
In-Reply-To: <f4bb0551-c21f-4d2d-a0ce-cea314869e86@fiee.net>
On 16 Sep 2024, at 12:15, Henning Hraban Ramm <texml@fiee.net> wrote:
>
> Am 16.09.24 um 12:59 schrieb Bruce Horrocks:
>>> On 15 Sep 2024, at 22:11, Florent Michel <florent.m42@gmail.com> wrote:
>>>
>>> Thanks Bruce for your very helpful reply!
>>>
>>> The reason for my question was indeed consistency, e.g. ensuring figure captions stay up to date with what the figures show when changing parameters. Thinking more about it, the second solution you mention seems to be a better option, though - I can simply define the parameters in an external file and read it from both the PDF solver and ConTeXt to ensure consistency. Thanks for mentioning it!
>>>
>>> Thank you also for mentioning \executesystemcommand, which I was not aware of!
>> Another option might be to use a marker such as
>> % DE_figure_here param1 param2 param3
>> in your ConTeXt source and then use 'awk' or another Unix text pre-processor to scan through for these, run the appropriate DE calculation, plot the graph and generate the appropriate \placefigure command to go in its place.
>> Bonus marks if it can automatically generate the caption based on the parameters! But if not, the marker can always follow the \placefigure macro e.g.
>> \placefigure
>> {This is a DE showing something and something else}
>> % DE_figure_here param1 param2 param3
>> so the awk code only needs to insert the image file name.
>> Note I’ve deliberately omitted the braces from the bit to be substituted so that you need to generate them in the awk. That way, if you forget to process, you’ll get an error not a missing image.
>
> That sounds needlessly convoluted to me.
> I’d use Aditya’s filter module to call external programs, it also does caching, i.e. if the parameters don’t change, it won’t waste processing time.
>
> https://github.com/adityam/filter
I think Florent already has a situation that can be described as convoluted. Whether this is more so only he can say.
I didn’t suggest the filter module to start with because it filters a buffer through an external command which isn’t Florent’s use-case (which is just the ability to call an external command). However I see, buried deeply in the docs, under the heading "Special use case: \write18 with caching” there is the ability to call a single command which would work.
Someone with better knowledge of the macro would need to explain how to adapt the ’size’ key to Florent’s usage to enable the caching.
Regards,
—
Bruce Horrocks
Hampshire, UK
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2024-09-16 12:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-14 20:46 [NTG-context] " Florent Michel
2024-09-15 20:29 ` [NTG-context] " Bruce Horrocks
2024-09-15 21:11 ` Florent Michel
2024-09-16 10:59 ` Bruce Horrocks
2024-09-16 11:15 ` Henning Hraban Ramm
2024-09-16 12:06 ` Bruce Horrocks [this message]
2024-09-16 12:58 ` Florent Michel
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=C6E57381-EA47-473D-9138-8C67C71E09F8@scorecrow.com \
--to=ntg@scorecrow.com \
--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).