For example,
!vim
in iPython opens vim. Is there such a thing in Octave?
The following might work system("vim");
If you want the interactivity of calling something inside of Octave and interactivity with it directly try exec("vim") instead.
See Controlling Subprocesses for more examples.
Otherwise you can either combine calls to system, fork and exec or extend octave with Python/iPython or C++.
If you only want to run another process then , the already suggested system() or exec() should work.
However, if you plan on using this to simply open up a text editor and edit an Octave file, set the value of EDITOR with EDITOR ("vim") (you can add this to your .octaverc file) and then use edit (foo) to open up the foo function on the text editor.
Related
I have a system that automatically creates and saves documents as html. For further storage they ought to be pdfs though.
I want to avoid having to do it manually so my preferred solution would be a small executable that I can call via command line, feed it with a source and output path (and ideally further parameters) and then let it do its magic. Something in concept like this:
exampleConverter.exe "C:\source\document1.html" "C:\convertedPDFs\document1.pdf"
No UI whatsoever, no human input, no popping up and closing console.
I looked through several options, but common problems I encountered were
the software not being free for commercial use
It just being a library of code, not a ready-to-go executable / code-base you just need to compile into one
The tool needing to get installed instead of being 'portable'
I'd like to avoid having to implement any modern libraries myself, partially for simple time concearns, partially because internally our code runs in a less than modern IE & VBS context so I for see compatibility problems.
Simply triggering a precompiled executable through a generic command line inerface that I can trigger from vbs seems like the perfect solution here.
Your Windows OS program code is almost there, why not reverse input and output (makes the task easier later), with a switch or two. you can embellish that with your for /? loop to run through the current working folder, just like any other program.
Your pseudo code
exampleConverter.exe --print-to-pdf="C:\convertedPDFs\document1.pdf" --headless "C:\source\document1.html"
Working Windows native code
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --print-to-pdf="%CD%\out\document1.pdf" --headless "%CD%\in\document1.html"
Other options are available
learn.microsoft.com suggest this working snippet to run edge with parameters
wscript vbsEdge.vbs
Dim shell
Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "msedge https://www.google.com --hide-scrollbars --content-shell-hide-toolbar"
So just combine the program methods. However, you need to sort out your own arguments.
For greater control then you need to step-up to heavier custom isations https://blogs.windows.com/msedgedev/2015/07/23/bringing-automated-testing-to-microsoft-edge-through-webdriver/ etc.
In RStudio it is Ctrl+Enter, while in PyCharm it is Ctrl+backslash, but I can't find a similar shortcut for Octave (not so interested in Matlab). There has to be a way to run a single line of code on the editor without running the entire document. I know there is a method to run chunks of code, but this doesn't seem practical, either.
You need to select the code that you want to run first. The actual shortcut to then execute the selection is configurable (Edit > Preferences...) but defaults to F9.
Or you can right click on the editor which shows you the options and shortcut:
Run tclsh command without any tcl file, the interpreter will go into interactive mode.
Can I simply disable this feature by modifying the tclsh source code ?
I can't imagine why you would want to bother doing this, given that supplying any script file will turn off interactive mode. The script you supply will have full access to the additional arguments passed in (a list in the global argv variable) and the standard IO channels (stdin, stdout and stderr). It can exit when it is done. Literally anything you want can be done at that point; you've just got to write a script to do it.
If you're including Tcl in your own program, the behaviour of tclsh is implemented in the C function Tcl_Main. If you never call that — instead just using Tcl_FindExecutable, Tcl_CreateInterp and Tcl_Eval/Tcl_EvalFile — then you never get any of that interactive behaviour. While theoretically you could modify the Tcl source itself to do what you want — it's all open source — why would you bother when you could just not call that code in the first place?
I have a problem with loading images and editing scripts in Octave. I think Octave has the wrong path or something. When I say 'edit', it says:
sh: 1: emacs: not found
What does that mean?
I'm pretty new to both Octave and MATLAB, but when I'm at school using MATLAB, for example, writing the command 'edit' works...
How do I know where to put files I want to load in Octave, and how do I change the path?
The problem is not with your path, the problem is that you didn't set up EDITOR (see help EDITOR and the editor option at help edit). As you have no environmental variable for it, it defaults to emacs so when you run edit, it tries to open the file in emacs and fails because you don't have it installed. Set up EDITOR for your text editor of choice at .octaverc file (If I remember correctly, the text editor to use is set as a persistent variable inside edit.m so you'll have to restart octave) or an environmental variable (I'd recommend this one).
It works in matlab because they made their own text editor. Octave is not a text editor, it's a programming language, it would be a waste of time to reinvent the wheel, and you should be able to choose whatever you are comfortable to code with.
Here are 2 :s commands. Work fine at command line or as part of a key mapping, but I cannot get them to run correctly in a vim script. I've used normal, execute, execute "normal..." and call normal on them. I've put the range with the s, and before normal, I've tried them with and without a : before the s. How should I write them within a .vim file?
:%s/<[\/]\?SPAN\|DIV\|OPTION[^>]*>//gi
:%s/<\(hr\|h[1-6]\|ul\|li\|p\|tt\|ol\|table\|tr\|td\|p\) [^>]\+/<\1/gi
You can put Ex commands like yours into a myscript.vim file, then execute the commands via
:source myscript.vim
This should work without modifications (you don't need the leading :, but it doesn't hurt). I don't see any problems, and you don't need :execute unless you want to include variables. :normal is for normal-mode commands (like diw, for example).
Typically, you'd place those custom commands into a function, though (which would be placed in ~/.vimrc or ~/.vim/plugin/myscript.vim), and invoke it via :call, either directly, via a mapping, or custom command.
You should just add them to a script. You don’t have to prefix them with anything in this case.