How to get output of Kotlin IntelliJ scratch file? - intellij-idea

A script as simple as
println("a")
doesn't produce any output in the Scratch output window. I expect an a to appear in the output window.
I'm using IntelliJ 2019.1.2 CE.

EDIT: Information regarding the expected functionality
According to a question I had asked: IntelliJ Ultimate Kotlin Script REPL skips first printed lines - Scratch Output cut off
It seems to be the case that the REPL wants to output per line, and will only overflow into the bottom area after a certain line length is reached.
In the question I state that I generally add some initial padding so that it always flows into the lower area with something similar to:
repeat(10) { println("BLANK ") }
END EDIT
You have to make sure that Interactive Mode is turned off at the top of the scratch window
This will cause prints to be put into the Scratch Output window.
Be warned, atleast in the version I have of IntelliJ ultimate 2019.1.3, the first 5-9 lines generally dont print so I do something like:
repeat(9) { println("blank") }

If you've defined everything inside of a function, the script won't execute the function automatically - you'll need to explicitly call the function.

You can create your own print, like this:
fun <T> myPrint(x: T) : T = x
then calling e.g.:
myPrint(5)
should show 5 in the result window.

Related

How to register the enter key using readline() in Kotlin

I am currently using readline() function in Kotlin. However, I want it to continue after registering the enter key ten times. I don't know how to do this.
using the function readline() on a console application that is reading from the keyboard, you dont need to register the enter-key because ENTER represents a valid end of the line. So a simple loop which is executed 10 times will fully work out here. for(i in 0..9) { <READ INPUT> }
Using it on files works the same. Normal editors will show a text in X lines if the border window is reached even without ENTER. readline() will not do that and read a single line in a file until a line-end sign is found. So here again - just loop it 10 times for 10 lines.
From your question it is not very clear, what you are trying to achieve. I assume you want to read ten lines from the console with Console.readLine().
The code
val lines = (1..10).map { readLine() }
will read ten lines from the console and store them in the variable lines as list of strings.

Matlab mex-function mexPrintf does not print immediately

This question hass been asked several times, but no solution does work for me. I want to use printf (or mexPrintf / ssPrintf) in an Matlab-mex file (called in a simulink s-function). The problem here is, that the output is only display after the function is finished, and I never get an instant message, while the function is running. I am using R2016b. I tried several things, like for example:
#define printf(...) { mexPrintf(__VA_ARGS__); mexEvalString("drawnow;"); mexEvalString("pause(0.01);"); }
I also tried the following solutions, but neither works:
how can I make a mex function printf while it's running?
https://de.mathworks.com/matlabcentral/answers/255615-why-are-mex-file-output-messages-using-mexprintf-mexevalstring-drawnow-not-printed-immediatel
Is there a way to get this working, or is this simply not possible in this release? Thanks.

IntelliJ idea deeplearning4j debugger has discrepancy in data

I work with deeplearning4j and created INDArray of quite big size. Into that array I write some values. If I try to see those values in debugger, initially I see zeros, and only for data at FloatBuffer I see entered values. See the screenshot.
If to debug the code of XorExample in deeplearning4j such behavior I didn't notice:
Is there any way to always show or always hide values that sit inside of INDArray without shoving zeros? Or it is some kind of bug inside of idea?
By default debugger evaluates and shows toString() defined in the NDArray class (or BaseNDArray in your case). You can replace it with your custom renderer for this type. The easiest way is to right click on a variable -> View as -> Create...
Or go to File | Settings | Build, Execution, Deployment | Debugger | Data Views | Java Type Renderers.
Then put your requred expression into "When rendering a node" expression.

To detect even number using LabVIEW

I was trying to make the even calculator without using code in LabVIEW but the problem was when i ran the code i get 0 between all the even numbers between 1-100.
I just want the even no in array not 0s.
What modification should i make for it.
Vivien's answer will not going to help you.
You are in right way. Just right click on the output terminal and select Conditional terminal. Remove case structure and connect your boolean line directly to the conditional terminal.
Please read here: https://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/condacc_valuesnloops/
PS. to get evens between 1-100 you should add 1 to iteration terminal (or you will have event between 0-99).
You can do something like this :

IntelliJ IDEA: Need help to set shortcut line

I am new to coding ... and i am using IntelliJ idea ... my question is ...
i want to make some shortcut for lines... like ...
System.out.println(); or
Scanner input = new Scanner (System.in); ..
and if i type like sop it will print ..system.out.println(); ... as those type of lines i have to use almost every code ... so it will be good if i can make shortcuts for those. is it possible to make this kinda shortcut in Intellij???
It's called Live Templates and there are a couple of them predefined. You can easily define your own.
The first one for System.out.println() is used by printing sout and then Tab.
A couple of the predefined ones can be found in Help -> Default Keymap Reference:
As you can see pressing Ctrl + J will bring up a list of available Live Templates.