How the heck do you use foreach in a custom expression?? Please, oh God, please someone document custom expressions!!
string allgroups = primgrouplist(“.”);
foreach i allgroups
{
xxx do something with group xxx
}
Please help…
Cheers,
Peter B
Foreach in custom expression?
2861 3 1- pbowmar
- Member
- 7024 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7708 posts
- Joined: July 2005
- Online
- Mario Marengo
- Member
- 941 posts
- Joined: July 2005
- Offline
edwardYes. Short answer is there *isn't* a foreach command for custom expressions. I believe the only functions available within a custom expression are functions from the expression language (i.e: the stuff you get from “exhelp”). So for loop control you have for and while and… that's about it.
This seems to work …
Here's another trivial example I just tried and it also works (useless since you can get this functionality from arg() and argc(), but just to see if it worked):
# Returns the group name given an (numerical) index
#————————————————————-
string grindex(string op, float ndx) {
string ret = “”;
if(ndx>=0) {
string gl = primgrouplist(op);
if(ndx<argc(gl)) ret=arg(gl,ndx);
}
return ret;
}
Which you can test in the textport with something like:
echo `grindex(“/obj/geo1/__display_sop__”,0)`
Cheers!
- pbowmar
- Member
- 7024 posts
- Joined: July 2005
- Offline
-
- Quick Links