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


Joined: 01 Sep 2005
Posts: 120

PostPosted: Sat Feb 25, 2006 5:23 pm   

Limit String List
 
Hi,

I got a string variable which has like 50 items...

Is there a comand to delete items from 31 - 50?

I just need the first 30 variables.

Toy mage
Reply with quote
CodeMaster Rapture
Newbie


Joined: 30 Jan 2004
Posts: 7
Location: USA

PostPosted: Sat Feb 25, 2006 7:27 pm   
 
Here's a method I use... rather ugly tho:

Code:

#var temp ""
#loop {1,30} {%additem(%pop(YOUR_LIST),@temp)}
#var YOUR_LIST ""
#loop {1,30} {%additem(%pop(temp),@YOUR_LIST);
#unvar temp


-CMR
_________________
Don't run! You'll only die tired!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Feb 25, 2006 9:55 pm   
 
Assuming the items are unique you can use:
#VAR List {%left(@List,%eval(%pos(%item(@List,30),@List)+%len(%item(@List,30))))}
If they are not:
#WHILE (%numitems(@List)>30) {#DELNITEM List 31}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
ToyMage
Apprentice


Joined: 01 Sep 2005
Posts: 120

PostPosted: Mon Feb 27, 2006 10:03 pm   
 
Hi,

This is what I do for the string variable actually.

This is basically a alias which I run to output the room number which matches a room name input. However some common names generate hundreds of variables.

#VAR QueryRoom %MAPQUERY( Name LIKE ~'~%%1~%~')

Can we limit the list to 30?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 27, 2006 10:31 pm   
 
Via SQL, you can. That's outside of the zscript scope, though, so it's up to the SQL gurus to say how to do it.
_________________
EDIT: I didn't like my old signature
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