Passing variables from the command line

I’m creating a batch of PDF documents in TeXmacs using data loaded from a CSV file. I want to automate the process so I can pass an argument on the command line that tells texmacs which row of the CSV to read.

Initially I thought I could just do texmacs -x "(define row-nr 8)" myfile.tm and be done with it, but this gives an error: Missing body expression.

I have found that I can define a variable in a .scm file and load that file with -x (load "row-nr.scm"), but that’s no so convenient to use in a shell script, for example.

I also found that I can do -x '(setenv "ROW_NR" "8")' and then do (getenv "ROW_NR") in TeXmacs (or of course just ROW_NR=8 texmacs .... This is probably the easiest solution.

I’m posting this here in case these solutions are useful to anyone. Please let me know if you have better solutions!

1 Like

Hi jeroen, why not do

texmacs -x "(begin
(load-buffer \"a.tm\")
(load-csv 8))"

Then ‘load-csv’ would load the date and manipulate the document tree with tree-set!? That would work as well. You can also define a variable in a .scm file, load that and then use set! from -x.