Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   How do you compare two strings in Alice? (http://www.alice.org/community/showthread.php?t=6085)

Vorrox 03-09-2011 06:17 AM

How do you compare two strings in Alice?
 
I am having a problem, where I want to use a while loop to compare two strings, and move on to an if statement once the condition is met. The condition being that the string must equal either "Trick" or "Treat". Once it equals either of those, I want it to run an if statement to check which one was entered, and then respond accordingly. I apologize if this doesn't make much sense, I am very tired.

reuben2011 03-09-2011 10:49 AM

[QUOTE=Vorrox;32017]I am having a problem, where I want to use a while loop to compare two strings, and move on to an if statement once the condition is met. The condition being that the string must equal either "Trick" or "Treat". Once it equals either of those, I want it to run an if statement to check which one was entered, and then respond accordingly. I apologize if this doesn't make much sense, I am very tired.[/QUOTE]

Try:

while stringVariable!="trick" and stringVariable!="treat"
{
Do nothing
}
if stringVariable =="trick"
{
//Insert methods
}
else
{
if stringVariable=="treat"
{
//Insert methods
}
}

debussybunny563 03-09-2011 07:50 PM

1 Attachment(s)
[SIZE="2"]Tell me if this is what you were looking for. If not, tell me what modifications there should be.[/SIZE]


All times are GMT -5. The time now is 03:18 AM.

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.