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
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sun Aug 18, 2002 7:09 pm   

Removing Items In A String List
 
I have a list that I need to remove the last three items from. The problem is, the items can be anything (text, numbers, special characters). Normally that wouldn't be a problem with the #delnitem command, but the list can be any number of items. There isn't really an effective way to count the number of items (the list is from a .txt file and changes constantly). Are there any ways to use pattern matching in the %replace or %remove functions, or anything similar? Something like this: #var matches %replace( @list, "^[alias-%-1] *$", "")

Any ideas?

Fat Tony
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Aug 18, 2002 7:57 pm   
 
You can count the number of items in the list by using %numitems. Thus, you can do this to remove the last three items:
#DELNITEM list %numitems(@list)
#DELNITEM list %numitems(@list)
#DELNITEM list %numitems(@list)

Kjata
Reply with quote
Burser
Wanderer


Joined: 07 Feb 2001
Posts: 70
Location: United Kingdom

PostPosted: Sun Aug 18, 2002 8:02 pm   
 
Would this work, too?

#LOOP 3 {#DELNITEM list %numitems(@list)}


---> Burser

|## - The flags have it.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Aug 18, 2002 8:09 pm   
 
It should work too.

Kjata
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sun Aug 18, 2002 8:38 pm   
 
Very cool, it worked, thanks guys.

Fat Tony
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