• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Query on 'assignstr' function

Harkan_again

Well-known member
Hi there

I'm trying to set a procedure up that is passed a tag name in the string format which then tags the target (in this case unit.children).

Running tests on it it works fine with the following:

var tagRet as number
tagRet = unit.assignstr("xxxxx.xxxx")

As soon as I change it to:

var tagRet as number
tagRet = unit.children.assignstr("xxxxx.xxxx")

I get an "Unexpected exception thrown during script evaluation" message. The file compiles with no issues and it is only when the procedure runs this is created.

The scenario is for a Division unit that can be assigned different nationalities, each of these affects the units that can be taken and the options each unit has. Being able to use a procedure where the tag name is passed as a string would mean one procedure rather than lots of repeated lines of code that tag and change the unit name

*edit* The format of set up within AB is the Division is a unit, it then has options that set the nationality. This script is being called from these options and is acting to change the name of the division, and tag child units of the division. Child units are controlled by live tags for each nationality, the units then have various options controlled by live tags for nationality

Any ideas with the exception thing or does assignstr not work to a unit.children level? I checked the authoring kit pdf and it does not mention assignstr

thanks
 
Last edited:
Hi Harkan,

Sorry for the late reply on this. I took a look into the code, and it appears that the "str" versions of the tag targets weren't implemented on the "children" transition, even though they're documented and it compiles properly - this is a bug in Army Builder that I'll log for fixing. :(

There are often better ways of doing things than using the "str" versions of tag targets. Instead of using a string, could you do something like:

Code:
if (tagis[nationality.nat1] <> 0) then
  perform unit.children.assign[nattags.nat1]
elseif (tagis[nationality.nat2] <> 0) then
  perform unit.children.assign[nattags.nat2]
(etc etc)

in your procedure?
 
That's the way I ended up going with it, was just hoping I could end up using a procedure passed a string to deal with it to create less lines of code as there are a lot of nationalities that the division can be

cheers as always
 
Back
Top