Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Fri Sep 03, 2010 5:53 pm   

Comparing individual characters in variables and string lists!
 
I need to compare single characters from a variable against single characters in a string list to see if they match.

For example if I have a variable set to "abc" and a string list, the first entry of which is "bcd" can I compare them and see if the first letter in the variable (being 'a') is the same as the first letter of the first entry in the string list (being 'b'). Also is the first letter in the variable equal to the second letter of the first entry in the string list, and so on.

Ideally I want to just use a #FORALL to compare the variable to every entry in the string list.

I know my way around cmud fairly well, just a kick in the right direction or a suggestion or anything would be great. Thanks
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Sep 03, 2010 6:06 pm   
 
1)some combination of %left(), %right(), %leftback(), and %rightback() to pull out the desired substring

2)%begins() to test against the beginning of a string

3)see #1 for testing against 2nd/etc letter of each element in the stringlist
_________________
EDIT: I didn't like my old signature
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Fri Sep 03, 2010 6:27 pm   
 
Also don't forget about %copy().
_________________
Unwritten Legends
Reply with quote
yorcadon
Beginner


Joined: 11 Jun 2009
Posts: 16

PostPosted: Fri Sep 03, 2010 6:27 pm   
 
That should work. Seems a bit sloppy combining %right and %left to reach the middle letter, but should work anyways.
Thanks!

Edit: %copy works perfectly. Thank you.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net