# Is there a non-persisting variable definition?

**URL:** https://www.finalbuilder.com/forums/t/is-there-a-non-persisting-variable-definition/275
**Category:** Discussion
**Created:** [December 1, 2006, 10:38am UTC](https://www.finalbuilder.com/forums/t/is-there-a-non-persisting-variable-definition/275 "2006-12-01T10:38:08Z")
**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: [December 1, 2006, 10:38am UTC](https://www.finalbuilder.com/forums/t/is-there-a-non-persisting-variable-definition/275/1 "2006-12-01T10:38:08Z")

</div>

I need to check for an environment variable, and if it doesn’t exist, then create it and assign a default value. In a batch file, this is simple:  
IF “%MyVar%”=="" SET MyVar=DefaultValue  
  
In FB4 I tried this:  
If Variable Defined  
Else  
 Define Variable  
 Set Variable  
 Append Variable  
  
The problem is that the first time I run the script, the environment variable is not defined, so it defines it. This definition persists in the project, so next time I run the script, it doesn’t look for the Environment Variable anymore, it just uses the project variable that was previously defined.  
  
I don’t see an Undefine Variable action that I could put at the end of the script. What should I do?

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [December 1, 2006, 11:19am UTC](https://www.finalbuilder.com/forums/t/is-there-a-non-persisting-variable-definition/275/2 "2006-12-01T11:19:06Z")

</div>

Hmm, good point. Would it be an option to fail the build if the environment variable doesn’t exist (ie. require that the environment variable exists).  
  
At the moment there is no way to either define a new environment variable or undefine a variable. Will discuss this issue next week with the team.

---

<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: [December 2, 2006, 12:55pm UTC](https://www.finalbuilder.com/forums/t/is-there-a-non-persisting-variable-definition/275/3 "2006-12-02T12:55:15Z")

</div>

Well I tried moving it to a user variable, hoping that I could manipulate the INI file, but it seems the the INI file is only updated when FB closes.  
  
I guess another option is to use 2 varaibles, the first one being the environment variable:  
If Variable Defined [Var1]  
 Set Variable [Var2=%Var1%]  
Else  
 Set Variable [Var2=DefaultValue]  
…and then work off of Var2 and forget about Var1
