Is there a non-persisting variable definition?

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?

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.

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