Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9252

Input vs. InputField for Interactive Applications

From Don <donabc@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Input vs. InputField for Interactive Applications
Date 2012-03-28 10:01 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jkunhb$aso$1@smc.vnet.net> (permalink)

Show all headers | View raw


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.

Don

User of Input function:

Remove[test];
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 *)

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 *)
test1[]

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Input vs. InputField for Interactive Applications Don <donabc@comcast.net> - 2012-03-28 10:01 +0000
  Re: Input vs. InputField for Interactive Applications A Retey <awnl@gmx-topmail.de> - 2012-03-29 07:57 +0000

csiph-web