# Macros don't recurse when used as environment variables?

**URL:** https://www.finalbuilder.com/forums/t/macros-dont-recurse-when-used-as-environment-variables/345
**Category:** Discussion
**Created:** [February 7, 2007, 8:18am UTC](https://www.finalbuilder.com/forums/t/macros-dont-recurse-when-used-as-environment-variables/345 "2007-02-07T08:18:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 7, 2007, 8:18am UTC](https://www.finalbuilder.com/forums/t/macros-dont-recurse-when-used-as-environment-variables/345/1 "2007-02-07T08:18:30Z")

</div>

I’m seeing a strange behavior with my variables. Some places they work as expected (such as in the Log Variables Action) but most places they behave oddly:  
  
Here is what I have:  
\_FB\_Dir\_Logs=(macro)"%\_FB\_Dir\_Work%\Logs"  
\_FB\_QI\_Log=(macro)"%\_FB\_Dir\_Logs%%\_FB\_QI\_LogFile%"  
  
When I display the variables (with DOS command “SET \_FB”), here is what I see:  
\_FB\_Dir\_Work=C:\NightlyBuilds\Q180  
\_FB\_Dir\_Logs=C:\NightlyBuilds\Q180\Logs  
\_FB\_QI\_LogFile=Q180-I5040  
\_FB\_QI\_Log=\Logs\<br\>  
I would expect \_FB\_QI\_Log to contain “C:\NightlyBuilds\Q180\Logs\Q180-I5040"  
It’s like it forgot to resolve those variables.  
  
  
  
I also have:  
\_FB\_Dir\_W=(macro)”%\_FB\_Dir\_Work%%\_FB\_QI\_LogFile%\Source"  
  
Which comes out like this:  
\_FB\_Dir\_W=C:\NightlyBuilds\Q180\Source  
  
So it looks like \_FB\_Dir\_W resolves one variable but not the other.  
  
  
  
What would cause this? And yes the variables are set as macros, I’ve checked several times, and saved and reloaded the project and still same problem.  
I’m using FB Pro 4.2.0.305  
Any ideas?

---

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [February 8, 2007, 12:02pm UTC](https://www.finalbuilder.com/forums/t/macros-dont-recurse-when-used-as-environment-variables/345/2 "2007-02-08T12:02:53Z")

</div>

IMHO, macro environment variables are not a good idea - you don’t know exactly when FB will “resolve” them, leading to possible race conditions between a process that is evaluating the environment variable, and an FB script that is altering the included variables.  
  
I find by far the safest and most reliable method is to avoid macros, and to explicitly set variables when they’re needed. You avoid all kinds of nasty surprises.   
  
Steve

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 8, 2007, 7:50am UTC](https://www.finalbuilder.com/forums/t/macros-dont-recurse-when-used-as-environment-variables/345/3 "2007-02-08T07:50:10Z")

</div>

OK, it seems that macro values are only updated when an action item uses them. I don’t think that they are updated if you try to pass them as environment variables.  
  
To work around this, I put a Log Variables action right before my command line and check-mark the variables I need updated.
