How to redirect Octave's console output to a separate console? - octave

If I have a function that displays a large amount of output, is there a way to display it all in the terminal separately (maybe using more or less), such that, upon exiting the pager, I get the Octave's console as is?
Like so:
octave:159> retVal = func_with_lotsa_output();
octave:160>
I seem to remember a previous version of Octave doing that by default (I'm currently on 3.8.1). Right now, the output is displayed before getting the prompt at line 160 (in between 159 and 160, that is).
I tried fiddling with PAGER, but to no avail.
EDIT: I've tried PAGER("more"), PAGER("less"), PAGER("pg"). I am unsure of what flags to try in PAGER_FLAGS(). Nothing has made a difference.

"When I exit the pager, I don't want to see the pager's output lying there."
Either your pager is broken, or you just need to activate the pager, with
page_screen_output(true)
or equivalently
more on
which, according to the documentation,
Turn output pagination on or off. Without an argument, more toggles the current state. The current state can be determined via page_screen_output.
If it still does not work, try with the "less" pager:
PAGER("less")

Related

TCL stack trace not showing desired error line number

The -errorline element of the return options dictionary for the following TCL script is "2":
puts [info patchlevel]
try {
error "this is an error"
} trap {} {result ropts} {
puts $result
puts $ropts
}
How do I get the stacktrace to display the line number in the source file where the error was actually raised (ie. line 4 instead of 2) ?
Example screenshot:
Tcl often has that information available, but doesn't use it.
It has the information available because you have a chance to retrieve it with info frame and getbytecode (which is in the tcl::unsupported namespace, mostly because we reserve the right to change how the bytecodes themselves work at any time). I'm not quite sure if that would work in your specific case, but if you put your test code in a procedure then it definitely would. (There are complexities here with fragility that I don't fully understand.)
It doesn't use it because, for backward-compatibility with existing tooling, it uses the line numbers it was using prior to the creation of the machinery to support info frame. Those line numbers are relative to the local script fragment (which is whatever reports the line number in the error info trace first); in this case, that is the body of the try.
I don't like that it works like that at all. However, changing things is a bit tricky because we'd need to also figure out what else to report and what to do in the cases where the information genuinely isn't available (such as for automatically-generated code where things are assembled from many strings from many lines).

PhpStorm - remove 200 responses from console when using built in PHP server

I am using PhpStorm and tried yesterday to use the built-in server functionality that it provides.
It works, but I find the console showing in bright red the 200 responses quite annoying, as it makes quite hard to spot real issues.
In the picture below you'll see what I mean.
Is there any way to disable these and only show for instance warnings (maybe in yellow) and errors (maybe in red)?
Use Grep Console plugin for this -- should do the job fine (does so in similar consoles).
Based on your requirements it allows you to:
change color for the matching text (or whole line if desired) based on presence of some marker (matching text)
or even hide (filter out) such line completely.
Your marker here could be [200]: for successful responses -- this is a simple "match the exact text" pattern. If it does not work (e.g. because this text is in the middle of the string .. or because it looks like regex (as [] have special meaning in regex)) then just convert it into proper regex: .*\[200\]:.* -- something like that should do.
Example of how it works:
The rule for that is highlighted (plain string as it's a very simple rule -- match exact string):

How do I use a function from one lisp file to solve for something in another lisp file?

I'm new to lisp and my professor gave some .lisp files to play around with.
http://pastebin.com/eDPUmTa1 (search functions)
http://pastebin.com/xuxgeeaM (water jug problem saved as waterjug.lisp)
The problem is I don't know how to implement running functions from one file to solve problems from another. The most I've done is compiled functions from one file and played around with it in the terminal. I'm not sure how to load 2 files in this IDE as well as how I should run the function. I'm trying, for example, to run the breadth-first-search function to solve the problem to no avail.
I'm currently using emacs as the text editor SBCL as the common lisp implementation along with quicklisp and slime.
Assuming each file is in its own buffer, say f1.lisp and f2.lisp, then you only have to call slime-compile-and-load-file when you are in each buffer. This is bound by default to C-c C-k. You have to compile the first file first, because it contains definitions for the second one.
But, your second file (f2.lisp) has two problems: search for (break and (bread and remove those strings. Check if the forms around them have their parenthesis well balanced.
Take care of warning messages and errors while compiling your file.
Then, if you want to evaluate something directly from the buffer, put your cursor (the point) after the form you want to evaluate, and type C-x C-e (imagine the cursor is represented by % below):
(dump-5 (start-state *water-jug*))%
This will print the result in the minibuffer, in your case something like #<JUG-STATE {1004B61A63}>, which represents an instance of the JUG-STATE class. Keep a window open to the REPL buffer in case the functions write something to standard output (this is the case with the (describe ...) expression below).
If instead you do C-c I, this will ask you which expression you want to inspect, already filled with the form before the point. When you press enter, the inspector buffer will show up:
#<JUG-STATE {1004BD8F53}>
--------------------
Class: #<STANDARD-CLASS COMMON-LISP-USER::JUG-STATE>
--------------------
Group slots by inheritance [ ]
Sort slots alphabetically [X]
All Slots:
[ ] FIVE = 0
[ ] TWO = 2
[set value] [make unbound]
Read http://www.cliki.net/slime-howto.

Octave equivalent of "hold all"

There is a nice command in Matlab called hold all, which causes subsequent plot commands to add to the current plot, using subsequent colours from the current colourmap.
But Octave says:
o.exe:248> hold all
error: hold: invalid hold state
error: called from:
error: C:\Programs\Octave\324_gcc440\share\octave\3.2.4\m\plot\hold.m at line 70, column 2
I've been using hold on, but all the lines a blue and similar, and I'm finding I'm spending too much brainpower trying to figure out which is which, rather than focus on understanding the pattern.
I'm looking for a solution that I can just type in, would rather not modify Octave's code or add scripts, for all the obvious reasons. Automatic colourmap rotation ought to have been the default behaviour, so maybe I'm missing something obvious...?
The option hold all already exists in Octave. The problem is that you're using a very old version of Octave. The current version is 3.6.4.

Catch Mathematica warnings/errors without displaying them

I have a problem involving NDSolve in Mathematica, which I run multiple times with different values of the parameters. For some of these values, the solution results in singularities and NDSolve warns with NDSolve::ndsz or other related warnings.
I would simply like to catch these warnings, suppress their display, and just keep track of the fact that a problem occurred for these particular values of the parameters. I thought of the following options (neither of which really do the trick):
I know I can determine whether a command has resulted in a warning or error by using Check. However, that will still display the warning. If I turn it off with Off the Check fails to report the warning too.
It is possible to stop NDSolve using the EventLocator method, so I could check for very large values of the function or its derivatives and stop evaluation in that case. However, in practice, this still produces warnings from time to time, presumably because the step size can sometimes be so large that the NDSolve warning triggers before my Event has taken place.
Any other suggestions?
If you wrap the Check with Quiet then I believe that everything should work as you want. For example, you can suppress the specific message Power::indet
In[1]:= Quiet[Check[0^0,err,Power::indet],Power::indet]
Out[1]= err
but other messages are still displayed
In[2]:= Quiet[Check[Sin[x,y],err,Power::indet],Power::indet]
During evaluation of In[2]:= Sin::argx: Sin called with 2 arguments; 1 argument is expected. >>
Out[2]= Sin[x,y]
Using Quiet and Check together works:
Quiet[Check[Table[1/Sin[x], {x, 0, \[Pi], \[Pi]}], $Failed]]
Perhaps you wish to redirect messages? This is copied almost verbatim from that page.
stream = OpenWrite["msgtemp.txt"];
$Messages = {stream};
1/0
FilePrint["msgtemp.txt"]