
Help!!!
Ok, I've gotten the code down to one foreach loop, but as Shadow pointed out, the loop doesn't search in any particular order and we really do need the values in order for them to be meaningful. I wrote out the code in a text editor and tried to copy it into HL for testing, but only a small portion of the code would fit in the eval script. I've spent the last couple days trying to shrink it down, but even without information lines (~) it is still well less then half of what I want.
I have two thoughts, but I'm not sure if either of them are viable.
First:
What is making the Foreach soooooo long is the level of redundancy. There is a block of code that is repeated at least 20 times with only a very slight variation based on a value in the eachpick.
Code:
if (eachpick.field[cIndex].value = [COLOR="Red"]1[/COLOR]) then
[I]using values on the eachpick and linkage[helper]
calculate values for what the increase to bab and
saves as well as HD progression (typically 1 for classes,
but may be more for race or template) and put these
values into various value fields in special [COLOR="Red"]xClsCnt1[/COLOR][/I]
endif
if (eachpick.field[cIndex].value = [COLOR="Red"]2[/COLOR]) then
[i]DO IT ALL AGAIN[/I]
put values in special [COLOR="Red"]xClsCnt2[/COLOR]
endif
etc
etc
I was originally doing all the calculations and such at the bottom of the script, but when I first started trying to trim things, it made sense to store the data someplace else so I could run a second eval scrip for those calculations.
The last entry on the Mathias thread for using math is from Adoxon
Why doesn't something like this work?
var id as string
hero.childfound[id].field[cGiveSpec].value+=1
but there is no followup, and I cannot find anything else about this. Is there a way to use variables in location codes? I could remove this redundancy, or at least the code side of it (the foreach is going to look at everything already

) if I can pull the value of the cIndex and use it to define where to save the data.
Example:
Code:
var index as number
var id as string
index = eachpick.field[cIndex].value
id = "xClsCnt" & index
[I]blah blah code blah[/I]
hero.childfound[id].field.... = data
nexteach
I thought I had come across a solution like this before, but I cannot find it now so maybe it was just wishful thinking.
Second:
While trying to find a solution to that id problem above I found lots of references for "findchild". I know foreach is bad for the cpu but what about findchild? If it is not as bad, then running a findchild in each of the specials might be a better way to go:
Code:
hero.findchild[ClassList,fieldval:cIndex = X].setfocus
my problem with testing this is that the test expression appears to only look at tags. Is this true?
One possible work around I was thinking was to use a foreach to search through all the ClassList and assign a user tag to everything.
Code:
var index as string
index = eachpick.field[cIndex].value
index = "cIndex" & index
perform eachpick.assign[User.(index)]
However the code above does not work, and this solution would only be viable if the findchild has very low cpu usage, which I am dubious about.