Thanks again Bruce! I had not thought about the possibility of parsing comments in the tex file from an external tool, but that sounds like a very good option. I like the fact that it would allow the tex file to contain all the information needed to keep track of what is represented without having to duplicate the parameter values. And since my specific workflow is indeed already convoluted it will not really add extra complexity.

Thanks also Henning for mentioning the filter module! I'll have a closer look into how I could use it - and it will certainly come useful, either for this project or a future one!

Best regards,
Florent

Le lun. 16 sept. 2024 à 13:08, Bruce Horrocks <ntg@scorecrow.com> a écrit :
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
___________________________________________________________________________________