I’ve got a copy command that I only want to fire if a variable is “1”.
I could put this in a If…Then Action, but it should properly be in the Execute Condtion of the Copy Action, right?
I’ve tried these statements (using VBScript):
_FB_App_CopySrc = 1
_FB_App_CopySrc == 1
_FB_App_CopySrc = “1”
_FB_App_CopySrc == "1"
and they all throw this error:
------------------------------------------------------
Error In Execute Condition (VBScript)
Copy File(s) [ %_FB_TFS_WF%%_FB_LoopVar% ] : Error In Expression:
Microsoft VBScript compilation error
Invalid character
Character: 2
This Action did not execute.
------------------------------------------------------
Does VBScript not allow underscores in the variable names, or what is my problem? I don’t really know VBScript, so if someone could show me what I’m doing wrong and how to do it right I’d appreciate it.
Thanks,
Mike
AFAIK, underscore in VB is a line continuation character. This is legal VB:
IF value _
= 300 _
then fail = 1
I don’t know what the workaround is.
Steve
Hi Mike,
I think Steve’s right… you’ll have to either convert your script to JScript or remove the _ in the variables.
.t8
Ok, apparently you can have underscores, just not at the start of the variable name. The workaround, should you need one, would be to create another variable with a “legal” name that expands (macro flag enabled) to %_FB_App_CopySrc%…
Steve
I got it to work. Javascript doesn’t seem to care about leading underscores in variable names.
I could put this in a If…Then Action, but it should properly be in the Execute Condtion of the >Copy Action, right?
Didn’t notice this remark before. Personally I have a strong preference for using If statements rather than the execute condition, for readability. You could very easily miss the fact that a certain statement doesn’t always get executed. An “If” is much more visible.
I don’t know if I would ever use an execute condition if I had the choice. Though, thinking about it now, I realise that an action group with an execute condition would act like a powerful if - you could express your condition in JScrpt.
Steve
We use the execute condition a lot in our builds. I agree it’s less readable, but using about 50 If’s is also not too readable either!
YMMV
Just a suggestion that I saw in this other product I worked on once - you could define flags that conditioned whether certain statements were run. Then each flag would appear as a checkbox column in the main view of actions. If the checkbox was ticked, that action would only run if that variable was true. If it was unticked, the action would run regardless of whether the variable was true or not.
Anyway just an idea for a solution that is both readable and doesn’t use Ifs I think this would work well in my particular case, as I have a large number of “If BuildType = Foo then do X” type commands.
Steve
And another idea is to select a unique colour for an action that has a condition… eg. Make it bright Red (only in FB5 though).
Ooh, I didn’t know about that one. Pretty. :)Steve
I don't know if I would ever use an execute condition if I had the choice. Though, thinking about it now, I realise that an action group with an execute condition would act like a powerful if - you could express your condition in JScrpt.
Steve
I actually use both depending on the situation. I use the normal IF action for big stuff when I want to see the structure, and I use execute commands when I want a quieter approach.
And yes using an execute condition on an Action Group is a way to get a more powerful IF, the exception being that there is no ELSE clause.
I guess I should wishlist scripted conditions for IF statements…
Steve
Just a suggestion that I saw in this other product I worked on once - you could define flags that conditioned whether certain statements were run. Then each flag would appear as a checkbox column in the main view of actions. If the checkbox was ticked, that action would only run if that variable was true. If it was unticked, the action would run regardless of whether the variable was true or not.
Anyway just an idea for a solution that is both readable *and* doesn't use Ifs :) I think this would work well in my particular case, as I have a large number of "If BuildType = Foo then do X" type commands.
Steve
That's kind of how I'm doing it. I have an INI file that has a bunch of boolean variables (value "1" is true, anything else is false) that I read at the beginning of the script. Then as the script executes it checkes these variables to see which components to build and which to not, which to copy and which to not, etc. The purpose for this is that I can have multiple INI files, each with a different configuration of build components, and I only have to point my build script to the correct one to get what I want built.
Interesting. Very different to the general approach here, which is “Build everything, then pick out the precise files you actually want afterwards”. When “build everything” means 15 minutes, you can get away with that.It means that the general problem is mostly reduced down to “what file do I copy, and where to?” But that question remains pretty complicated.Steve