Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value in input octave

Is there a method to add a default value for input? (in Octave ) Sounds so simple but I can't find it. I just want to give the user a possibility to pres ENTER if the default value is ok, or to change it and then ENTER.

like image 652
user1189768 Avatar asked Apr 11 '26 01:04

user1189768


1 Answers

You can try something like this:

function val = get_response(default="Y")
  val = input("Your choice? [Y]/N ", "s");
  if isempty(val)
    val = default;
  endif
endfunction

I wrapped this into a function but you can use the enclosed code directly, of course.

like image 179
chl Avatar answered Apr 23 '26 16:04

chl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!