[solved] a simple UI.inputbox problem
-
hi,
just a simple UI.inputbox-problem:why does this simple method not work?
#*************************************************************************** def one_value_input #*************************************************************************** get_single_value ["a"],["b"],["c"] end#def #*************************************************************************** def get_single_value (prompts, defaults, headline) #*************************************************************************** puts prompts #>>> puts a puts defaults #>>> puts b puts headline #>>> puts c input = UI.inputbox(prompts,defaults,headline) end#defthe picture shows, what comes from it....no idea, why ! (and the "c" appears in the pulldown ....
thanx
stan

-
An inputbox takes three OR four arguments.
promptarray, valuearray, popsarray, titlestring
The first two arguments must always be arrays.
The first one contains string elements used as the prompts.
The second one can contain various elements - string ["cat"], float [1.2], integer [6], length [25.mm]
There must be a third argument of some kind.
If you pass the third element as an array you can get a drop-down if you pass a non-empty string.
If the default value is NOT on the passed list-string then it'll start with a 'blank'.
If you pass three arguments and the third is a simple string, then that is used as a 'title'.I your case with a one item inputbox:
results = inputbox(["Choose Item: "], ["a"], ["a|b|c|d|e"])gives a fixed list to choose from ('a' to 'e', defaulting at 'a') BUT NO 'title' [since you pass NO string].
Note how the elements of the drop-down list are separated by '|'...Whereas:
results = inputbox(["Type in a String: "], ["?"], "Title")gives an inputbox expecting a string to be typed NOT chosen, with the default of '?'
To complete the permutations and extend the example a little, this example below gives you a two item inputbox, expecting a typed in response AND list to choose from, and a also has a 'title':
results = inputbox(["Typed: ", "Chosen: "], ["?", "a"], ["", "a|b|c|d|e"], "Title")To get the results into two variables ('typed' and 'chosen') use:
return nil unless results ### in case user Cancels! typed,chosen = results -
hi tig,
understood and done, works perfect,
the combi-version is very nice and confortable and i can pass arguments to it from any method.
you will then see it in the finished ruby!
thanx a lot for the explanation.
stan
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement