Psuedo-code of the problem:
MyVar is defined as project variable (Yes - Make Available as Env Var)
Set MyVar = “1.0”
Include Project - (Yes - Reload Environment Vars, No - Share Host Variables)
If “%MyVar%” <> “1.0” then FAIL
This will fail. and MyVar’s value will be 1
Problem does not occur if MyVar is set to 1.1, or other non-zero to right of decimal.
I believe I can work around the issue in my case, but I thought I’d bring it to VSoft’s attention.
Thanks!
Hi Nelson
This occurs due to how FinalBuilder attempt to detect the type of the variable value, it would see 1.0 as an integer and thus drop the decimal point. On of the things we have planned for the next major version of FinalBuilder (and automise) is to allow users to strongly type variables (optional though). So if you specify a variable is a string it will always be treated as such.
To work around the problem you will need to use the set variable action and specify the type as string (using the Force Type options at the bottom of the action properties page).
Hi Vincent,
I tried the workaround, but it doesn’t seem to work when I use the Include project action and specify Reload Env Variables and uncheck share host vars. I’m attaching an example project to demonstrate.
Thanks!
-Nelson002_001_FB_LosingDecimalProblem.zip (3.181 KB)
Hi Nelson
Thanks for the example… demonstrates the problem clearly and concisely. I will look into it and get back to you.
Hi Nelson
This is not a bug, but it is a gotcha that took me a while to figure out!
When you make a variable available as an Environment variable, it’s value is stored in the environment block rather than in memory. When the Include Project action has the “Reload Environment variables” option enabled, the reset code for variables is applied to the environment variable (MyVar)… which in turn changes the value of the variable in the host project because the storage for the variable is the environment block.
The issue really is the untyped nature of FB variables, and our attempts to infer the type from the value. 1.0 is seen as a number, and it’s seen as a whole number so the .0 gets removed in the type conversion.
So for now the work around is to turn off “Reload Environment variables”, it’s not really needed in most cases and I’m not sure why we have it as the default.
Ahh, I see. Thanks for the in depth investigation and response! The work around sounds reasonable.