Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How do you compare two strings in Alice?
Old
Vorrox
Guest
 
Status:
Posts: n/a
Default How do you compare two strings in Alice? - 03-09-2011, 07:17 AM

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.
   
Reply With Quote
Old
reuben2011
Senior Member
 
reuben2011's Avatar
 
Status: Offline
Posts: 489
Join Date: Sep 2009
Location: Hawaii
Default 03-09-2011, 11:49 AM

Quote:
Originally Posted by Vorrox View Post
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.
Try:

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


Projects
-Escape the Kitchen
-That ninja animation
-Hill Collision

Upcoming Projects
-Some penguin adventure game?
   
Reply With Quote
Old
debussybunny563
Senior Member
 
debussybunny563's Avatar
 
Status: Offline
Posts: 852
Join Date: May 2010
Arrow 03-09-2011, 08:50 PM

Tell me if this is what you were looking for. If not, tell me what modifications there should be.
Attached Files
File Type: a2w stringComparison.a2w (491.7 KB, 13 views)


Last edited by debussybunny563; 12-21-2012 at 12:00 AM.

|--------------------------------------------------------------------------------------------------|
|Link to weapons collection: http://www.alice.org/community/showthread.php?t=7368 |
|--------------------------------------------------------------------------------------------------|

I have been dead for quite some time now; not much hope for resurrection.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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