Home > Software engineering >  How to continue to next loop iteration only if I press a certain key in Julia
How to continue to next loop iteration only if I press a certain key in Julia

Time:11-08

I am using Julia in Atom. I have a for loop which prints out information in each iteration. I want Julia to pause the program at the end of each iteration so that it only continues to the next iteration if a certain key is pressed (for instance, say the 'enter' key) in the REPL. How should I do this?

CodePudding user response:

The following should work (in REPL as well) :

for i in 1:3
    # ...
    println("something")
    readline() # wait for enter key press
end

Using readline() captures keystrokes (which you can assign to a variable to actually read them) until you press enter.

  • Related