|
Macgomes Newbie
Joined: 16 Jul 2019 Posts: 1
|
Posted: 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. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
|
|
|
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
|
|