MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Input vs. InputField for Interactive Applications

  • To: mathgroup at
  • Subject: [mg125679] Input vs. InputField for Interactive Applications
  • From: Don <donabc at>
  • Date: Wed, 28 Mar 2012 04:59:23 -0500 (EST)
  • Delivered-to:

I am trying to do something very simple.

At a place inside a function, I am asking the user
to input the lower case letter a (for automatic) or
a series of integers (representing months from Jan. to Dec.
The integer numbers can be separated by commas AND/OR spaces) .

After the user has input either the lower case a 
OR a series of integers in the range 1 to 12 inclusive,
the function takes this input and performs certain 
actions based upon the input from the user.

That's it !  That's the whole problem.

I have two choices with Mathmatica, it appears, 
to do the simple task outlined above:

(1)  I can use the Input function.  The trouble with this is that
a series of integers looks like a multiplicaiton to Mathematica
and it wants to multiply the integer numbers  - clearly not
what I need as input. 

(2) I can use the InputField function.  The troulbe with this
is that it puts out an input field, but then doesn't wait
for the user to input the list of integers.  It immediately
goes to the next line of code and executes that, and so on.

I need a hybrid of the Input and InputField functions.

Examples of what's wrong with the Input 
and InputField functions are demonstrated below.

Thank you for any help you can give me.


User of Input function:

test[] := Module[{},
    input = Input["Input a series of montly integers OR the lower
      case a [for automatic] to leave out all months with an Avg. \
Negative TR
      and then hit OK"];
   ];(* End Module test *)


Use of InputField function:

Remove[test1, s];
test1[] := Module[{},
   s = "";
   Print[Column[{InputField[Dynamic[s], String, 
       FieldHint -> "Enter series of integers for the months
        separated by spaces or commas"]}]];
   response = 
    Dynamic["{" <> 
        StringReplace[StringReplace[s, "," -> " "], 
         Whitespace -> ","] <> "}" // ToExpression // Flatten];
   Print["test1 functon has not waited for the input"];
   ];(* End Module test1 *)

  • Prev by Date: Typesetting in Mathematica (TraditionalForm typesetting?)
  • Next by Date: Re: calculation error in series
  • Previous by thread: Re: Typesetting in Mathematica (TraditionalForm typesetting?)
  • Next by thread: Re: Input vs. InputField for Interactive Applications