Lyx: Calling external script/program - knitr

I have a program that generates LaTex output. I'd like to have Lyx execute that program on the fly (much as R scripts are executed on the fly by knitr) and incorporate the LaTex output into the document. Is there a way?
The hack is to use knitr and wrap my program in some R code using system(). This works, but... it's a hack, and you have to play games to get the output to work right. If there's a clean, native Lyx solution, that would be better!
Thanks!

Related

How can I print the output of each line in an .ml file

I have an .ml file and I want to be able to run it line-by-line as if I was typing it in the top-level ocaml interpreter
The problem is, if I simply type "ocaml file.ml" in the terminal, I don't get the output from the REPL, and I can't debug and compile it, since it contains the #use directive.
I've tried using several different extensions for Visual Code, but none of them worked for me.
Is there anything I can do to simply be able to run the file and get the output from the ocaml REPL?
Thanks.
I never used VS Code (if you are referring it as 'Visual Code'), but SLIME in emacs or its Vim version of it is probably what you want.
Based on that, I tried searching for an VS Code extension that does works like SLIME: SendToREPL.
(Disclaimer: the author claims it works for Python, Node, and reply (not sure what it is though), but I am quite confident that it will work for OCaml REPL/UTop.)

Formatted text in the command window

I know of the cprintf Undocumented Matlab way of changing the color and other font properties in the command window but I also saw this symbols in plots. This shows that Matlab supports TeX markup in plots at least. I played with it for a while and found it very useful. So much so that I wanted to find a way to include this in the command window.
I first tried sprintf('\color{red} Something\n') and was rewarded with an error that \c is not a recognized escape sequence. Google was no help either.
This is a way to use the some of the other formatting options in the command window?
The command window doesn't support TeX. Sorry. The TeX support is part of the routines that generate the figures, not the code that displays the command window.
In essence, the command window is, by modern standards, a pretty boring terminal emulator. There's not much you can do with it.
If you're looking for something to do math in that generates fancy notebooks on the fly that combine the commands you type and their results in a nice-to-read, modern way, you might just want to avoid Matlab and have a look at Jupyter (formerly IPython) Notebooks, which of course support MathJax (and thus, LaTeX math syntax): https://try.jupyter.org/

Perl: list the lines being run

I am debugging big perl program. To minimize debugging I would like only to debug the lines actually run.
Is there a tool which I can run my program under, that will give me a program only containing the lines actually being used (e.g. by commenting out the rest)?
You can use the Perl Debugger (http://perldoc.perl.org/perldebug.html).
Decent beginner's write up: http://www.thegeekstuff.com/2010/05/perl-debugger/
It sounds like you might want a coverage tool, like Devel::Cover, which indicates the lines which are being executed during a run of the code.
For example, where you currently execute your code as
perl yourprog args
instead you run
perl −MDevel::Cover yourprog args
cover
This will generate an HTML report showing the code which is actually executed.

How to run Abaqus Macro (.py) script

I am new to python. I generated a macro which is a .py script using Abaqus Macro manager. I realised that this script works only when run from the Abaqus manager and does not run by itself.
Please does anyone know how to modify this script so i can run it without using the Abaqus. Thank you in advance for your help
Adroit
to run a python script that relies on abaqus cae from the command line and without opening up the gui window you do:
abaqus cae noGUI=script.py
As mentioned if all the script does is define a macro, well that's all it does is define the macro and quit. Typically you need to add code to open an odb, do something, write output, etc.
In general, Python scripts can be run in Abaqus via 'File > Run script'. However, as is a case for all Python scripts, if all your code is contained inside of a function (and in case of Abaqus macro, it is), and that function is never called explicitly inside the script, the code will not be executed.
You file probably looks something like this:
from abaqus import *
# some other imports, if any
def macro_function():
# code defining the macro's behavior
You should edit the script by calling the function at the end of the script.
If you want some more concrete help, post your actual code.
EDIT: To call the defined function, you just write macro_function() at the end of the file, so that the script looks something like this:
from abaqus import *
# some other imports, if any
def macro_function():
# code defining the macro's behavior
macro_function()
Maybe it would be easier if you just had the code outside of the function and remove the function completely. For anything more than this, you really should learn some Python.
According to my moderate experience, if you need loop computations, you have to launch the script inside CAE, since when starting it in command line, only one cycle is computed. An example of the script intended for loop computations and visualisation, you can find at researchgate, search text "How to write scripts for Abaqus"

Code generator for CLI based on CLD file

Although programming using the CLI$ routines is not very hard, it would be nice if there were a code generator for the basic stuff based on the CLD file. Does anyone have something like that, or is there anyone interested in it?
There is a code generator of sorts at http://www.tomwade.eu/software/vmsarg.html
This is designed for when you're porting a C program onto VMS that is set up to use the typical terse and unfriendly qualifiers like
$ mumble -f -l foo.txt
that Unix loves. It generates code that allows the program to accept
$ mumble /fast /log=foo.txt
and translates it into the hieroglyphics that the program expects. Add CLD like functionality to the program with minimal C coding.
It sounds like you have used enough of the features of CLDs that it would be a project to write a TECO macro to massage the CLD into the corresponding MUMPS code. (Sorry, wrong language?) Even LIB$TPARSE, or its Alpha replacement, would take some time to wrangle. Sounds like you have a "boring job" ahead of you, or a co-op. (Named for the sound it makes when it hits the wall.) Or find a YACC guru or someone with facility at various other parsing tools and turn them loose.