class HelloWorld
{
static Void main()
{
Env.cur.out.print("Insert a number: ")
x := (Env.cur.in.readLine).toInt
if (x < 0) echo ("Number is < 0")
else if (x == 0) echo ("Number is 0")
else echo("Number is > 0")
}
}
i won't use echo (coz it goes with newline) so i tried another way.. it's very strange (to me) that running this code the program hangs waiting for the input BEFORE writing the string "Insert a number"... then, when i put a number from the keyboard and press enter my strings appears one after the other, this way:
D:\fantom1063\bin>fan iftest.fan
-5
Insert a number: Number is < 0
why?
thx again.
andySat 22 Sep 2012
Might to try flush:
Env.cur.out.print("...").flush
ScherenSun 23 Sep 2012
Ok, tk u. Why this behaviour?
brianMon 24 Sep 2012
Because your output is buffered in memory and not written to console until you either explicitly flush it or a call like printLine flushes it.
Scheren Fri 21 Sep 2012
Here i am with another silly question
i won't use echo (coz it goes with newline) so i tried another way.. it's very strange (to me) that running this code the program hangs waiting for the input BEFORE writing the string "Insert a number"... then, when i put a number from the keyboard and press enter my strings appears one after the other, this way:
why?
thx again.
andy Sat 22 Sep 2012
Might to try
flush
:Scheren Sun 23 Sep 2012
Ok, tk u. Why this behaviour?
brian Mon 24 Sep 2012
Because your output is buffered in memory and not written to console until you either explicitly flush it or a call like printLine flushes it.