Re: Beginner--Simplest question: How to control some values in Input dialog box
- To: mathgroup at smc.vnet.net
- Subject: [mg67755] Re: Beginner--Simplest question: How to control some values in Input dialog box
- From: bghiggins at ucdavis.edu
- Date: Thu, 6 Jul 2006 06:53:45 -0400 (EDT)
- References: <e8fuj0$qm0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
If you are not using webMathematica then one approach is to do the
following for say the CN parameter
inputTest[x_] := Switch[x, _?(IntegerQ[#] && # > 0 &),
CN = x, _?(! (IntegerQ[#] && # > 0) &), inputTest[Input["Your
input
was not a positive Integer!\nPlease give an positive integer value
to CN"]]]
inputTest[Input["Give an positive integer value to CN"]]
This test will continue to display a dialog box until the user inputs
the correct data. One can readily modifythe test to "break if you have
say more than 5 unsuccessful tries by inserting a counter into the
test.
If you are using webMathematica and the input is through a html Form
construct, then the best way is to use JavaScript that tests the form
input before passing the input to the webMathematica server.
Hope this helps,
Brian
abdou.oumaima at hotmail.com wrote:
> Hi mathematica users,
>
> In the begining of my program, I've to initialize some parametres. I would like to do some control on them.
>
> I put:
>
> CN= Input["Give an positive integer value to CN"];
> c= Input["Give a positive real value to c less than 0.9"]
>
> How to control the values CN and c so that they verify my conditions in the message box?
>
> Any help please.
>
> Thank you for all of you
>
> Link to the forum page for this post:
> http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Special:Forum_ViewTopic&pid=11670#p11670
> Posted through http://www.mathematica-users.org [[postId=11670]]