|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sat Jan 21, 2006 12:53 am
Optimising Multiple For_all loops? |
I am looking for a way to optimze this alias, for use in other applications (so I dont have to right one for each possible combination of skill groups)
I think the best way would be with multiple forall loops, but I cant figure out how to impliment them.
Currently i have variables of the form
#var index_glory skill1|skill2|skill3
#var Glory ""
#addkey Glory Skill1 LevelofSkill1
#addkey Glory Skill2 LevelofSkill2
#addkey Glory Skill3 LevelofSkill3
Code: |
#priority {
#var needspracticed -1
#forall @index_glory {#if %db( @glory, {%i})=@servant_level {#additem needspracticed {%i}} {#NOOP}}
#forall @index_grace {#if %db( @grace, {%i})=@servant_level {#additem needspracticed {%i}} {#NOOP}}
"Additional ForLoops for each group removed for this example", but they all continue in the same form IE: #forall @index_Group {#if %db( @Group, {%i})=@servant_level {#additem needspracticed {%i}} {#NOOP}} "
#if %numitems( @needspracticed)=1 {#var needtopractice 0} {#var needtopractice 1}
}
|
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sat Jan 21, 2006 3:04 pm |
You should be able to make an alias that accepts the group name as a parameter and then executes your loop. It's not exactly faster, but it would make your life a little easier.
Code: |
#ALIAS checkgroup {#forall @index_%1 {#if (%db(@{%1}, %i) == @servant_level) {#additem needspracticed {%i}}}} |
I'm not sure why you have a separate index list, however. If it's used in other ways, that's okay, I guess, but with what you've shown here, you could just iterate over the data record itself without the need for an auxiliary string list (i.e., replace #forall with #loopdb and change your #if a little). |
|
|
|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sun Jan 22, 2006 3:31 am |
I forgot about #LOOPDB, I'll look into giving that a try.
|
|
|
|
|
|
|
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
|
|