-
• #2
With console.log() had expected that... but with print() there usually goes also a println()... like write() and writeln()... but I'm obviously mistaken.
-
• #3
print
is exactly the same asconsole.log
in Espruino - it's really there just to make it easier for learners...If you know where the console is (eg. Serial1) you can just do
Serial1.write
- but you should be aware that you can totally mess things up -console.log
actually removes the current line(s) being input in the console before writing your text (the current input line is then put back when your JS function has finished executing) -
• #4
So there's no way to print long lines incrementally, one has to build the string in memory and then print it at once? Sigh.
-
• #5
I can't say I'm fond of a .print() method appending line ending. That's what .println() methods should be for.
-
• #6
Well,
Serial.print
doesn't print a line ending,Serial.println
does. It's justprint()
that's there - a bit confusing, but handy for people new to JS who just want to do 'Hello World'.To be honest it looks like a JS thing - it's not just Espruino: http://stackoverflow.com/questions/6157497/node-js-printing-to-console-without-a-trailing-newline
If you want to print a bit of a line at once, do
console.log()
which will print a newline (but will clear off the current input line and make sure it gets put back). Then useUSB.print()
or similar.I guess to make it more compatible I could make
process.stdout
andstdin
point to the current Serial device.
Dumb question: is there a way to print a string to the console without newline? Both console.log() and print() add a newline.