|
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: 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 |
|
|
|
CodeMaster Rapture Newbie
Joined: 30 Jan 2004 Posts: 7 Location: USA
|
Posted: 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! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: 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? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
|
|