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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Macgomes
Newbie


Joined: 16 Jul 2019
Posts: 1

PostPosted: Tue Jul 16, 2019 10:18 am   

zMUD General Discussion
 
Hello everyone,,,
I have 2 string lists to compare, assume they are as follows:

#VAR colourCheck= {red|black}
#VAR colours= {red|blue|orange|red|orange|green|black|red}

I would like the resulting string list to read:

#VAR colourFound= {red|red|red|black}



Essentially I would like to check the first value in <colourCheck> sequentially against every value in <colours>, then the second value and so on. I am using %additem so i can repeat instances of the same word in the resulting list.

Thanks in advance for the help.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Tue Jul 16, 2019 10:38 pm   
 
First off i have to comment on the bad syntax of the variable declarations you present (no offense meant, just trying to help.)

Either
#VAR colourCheck {red|black}
or
colourCheck = red|black

On to your question, you want a #FORALL loop, an #IF statement and the %ismember function (use #HELP to read the instructions for either), in addition to the %additem you already mentioned.

colourFound=""
#FORALL @colours {#IF (%ismember(%i @colourCheck)) {#VAR colourFound {%additem(%i, @colourFound)}}}
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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