# Readline \<CR\> behavior

**URL:** <https://discourse.julialang.org/t/readline-cr-behavior/71317>\
**Category:** New to Julia\
**Tags:** vscode, io\
**Created:** [November 11, 2021, 8:31am UTC](https://discourse.julialang.org/t/readline-cr-behavior/71317 "2021-11-11T08:31:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [November 11, 2021, 8:31am UTC](https://discourse.julialang.org/t/readline-cr-behavior/71317/1 "2021-11-11T08:31:57Z")

</div>

Hi,  
when I execute the code below, the input does not end up in the correct variables.  
It needs more returns than expected to finish, everthing appears shifted by one or more returns.  
([HackerRank](https://discourse.julialang.org/t/what-other-language-allows-you-to-do-rational-matrix-inversion/20340) challenges depend on console input)

```julia
println("enter integer i <CR> decimal d <CR> string s <CR>")
i = readline();
d = readline();
s = readline();
println("done")

```

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [November 11, 2021, 9:17am UTC](https://discourse.julialang.org/t/readline-cr-behavior/71317/2 "2021-11-11T09:17:44Z")

</div>

I put this code in a file `a.jl`, then in Julia I run `include("a.jl")`. This is what I get in the REPL:

```julia
julia> include("a.jl")
enter integer i <CR> decimal d <CR> string s <CR>
1 # I wrote this and pressed Enter
2.3 # I wrote this and pressed Enter
hello # I wrote this and pressed Enter
done

```

Then I have the string `"1"` in the variable `i`, etc. Is this not what you expect?

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [November 11, 2021, 9:30am UTC](https://discourse.julialang.org/t/readline-cr-behavior/71317/3 "2021-11-11T09:30:19Z")

</div>

Thx, your way the code is working as expected.

I have the code in a file scratch.jl in VScode and press the triangle.  
Then

```julia
julia> 

enter integer i <CR> decimal d <CR> string s <CR>
julia> 1
1.1
"toto"

done

julia> 1

julia> i
"1.1"

julia> d
"\"toto\""

julia> s
""

```

Where does the difference come from? Can this be aligned?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [November 11, 2021, 10:04am UTC](https://discourse.julialang.org/t/readline-cr-behavior/71317/4 "2021-11-11T10:04:35Z")

</div>

Don’t use `readline()` (or other stdin methods) together with inline evaluation in VS Code, [it’s known to be broken](https://github.com/julia-vscode/julia-vscode/issues/785).
