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
astrotaz
Beginner


Joined: 09 Aug 2011
Posts: 12

PostPosted: Sat Feb 10, 2024 2:49 pm   

Stringlist reordering
 
Can someone help me with this problem.

I have a stringlist which contains the following

#var numbers {one 1-1|two 2-2|three 3-3|four 4-4|five 5-5|six 6-6|seven 7-7|eight 8-8}

I want to be able to input a starting element which is known to be in the list already, and do the following

1. remove that element from the list
2. Take all the elements before the removed element and append those elements to the end of the string list

For example if I provide four 4-4

I want this to build a new stringlist which would now contain...

#var numbers2 {five 5-5|six 6-6|seven 7-7|eight 8-8|one 1-1|two 2-2|three 3-3}

Can someone help me with this these manipulations

Ultimately I want this to be contained within an alias

so I can type <aliasname> four 4-4 and it performs the above manipulations for any provided element name

Thanks
A.
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Thu Feb 22, 2024 3:52 am   
 
Would an alias for a #SW be enough?
Code:

<aliasname> (%1)

@numVar = %1
#SWITCH (@numVar)
  (1-1) {@numbers = "one 1-1|two 2-2|three 3-3|four 4-4|five 5-5|six 6-6|seven 7-7|eight 8-8"}
  (2-2) {@numbers = "two 2-2|three 3-3|four 4-4|five 5-5|six 6-6|seven 7-7|eight 8-8|one 1-1"}
  (3-3) {@numbers = "three 3-3|four 4-4|five 5-5|six 6-6|seven 7-7|eight 8-8|one 1-1|two 2-2"}
  (4-4) {@numbers = "four 4-4|five 5-5|six 6-6|seven 7-7|eight 8-8|one 1-1|two 2-2|three 3-3"}
  (5-5) {@numbers = "five 5-5|six 6-6|seven 7-7|eight 8-8|one 1-1|two 2-2|three 3-3|four 4-4"}
  (6-6) {@numbers = "six 6-6|seven 7-7|eight 8-8|one 1-1|two 2-2|three 3-3|four 4-4|five 5-5"}
  (7-7) {@numbers = "seven 7-7|eight 8-8|one 1-1|two 2-2|three 3-3|four 4-4|five 5-5|six 6-6"}
  (8-8) {@numbers = "eight 8-8|one 1-1|two 2-2|three 3-3|four 4-4|five 5-5|six 6-6|seven 7-7"}
  {No Match}
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