MathGroup Archive 2010

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

Search the Archive

Re: newbe question about Sting Comparison

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107017] Re: newbe question about Sting Comparison
  • From: JH <jlucio at ubu.es>
  • Date: Sun, 31 Jan 2010 07:59:16 -0500 (EST)
  • References: <hk3nsk$alp$1@smc.vnet.net>

On 31 ene, 12:00, "Biff. Bartolemew" <harrytuttle... at mac.com> wrote:
> Hello,
>
> I hope someone can help me out, and not laugh to hard at my stupidity,
> but, I am trying write a little program
>
> playAGame[] := Module[
>      {car},
>      ans = Input["Would you like to play a game"];
>      Print[ans];
>      If[ans == "yes", Print["you answered yes"],
>          Print["you did not answer yes"]
>      ];
>      If[5 == 5, Print["You suck"], Print["You Rock"]];
>
>      ]
>
> The first If statement does not seem to be evaluated.
>
> Yet, if I type:
>    "yes"=="yes",   I get the answer I am looking for.
>
> It seems like the string comparison is acting different in the middle of
> the If statement.  Can someone tell me what I am doing wrong?
>
> -Thanks

Hell:

Use InputString (expects a string, it is what you want) instead of
Input (expects an expression).

    JH.


  • Prev by Date: Re: newbe question about Sting Comparison
  • Next by Date: Re: newbe question about Sting Comparison
  • Previous by thread: Re: newbe question about Sting Comparison
  • Next by thread: Re: newbe question about Sting Comparison