#1
|
|||
|
|||
Can't get DATETIME macro value
Hi folks, in a script step, I'm assigning the DATETIME macro value as follows:
macro.Value = [DATETIME] but I get nothing in the relevant macro. If I replace this with: macro.Value = [DATE] I get the macro value coming back properly with the relevant date. If I look in the system macros list, I can clearly see the DATETIME macro there. There's no hint of any errors and I've searched the forums here with no luck. I could write a funtion to get the date/time or use the Format...VSS function I came across in another thread, but this seems to be a fundamental thing which should work. Anyone have any ideas? I'm using version 5.0 of Visual Build, running on w2k. Thanks in advance. Sam. |
#2
|
|||
|
|||
The problem you are encountering is that the DATETIME macro contains a space, and you aren't quoting the macro value in the assignment.
Something like this will work better: Application.Macros(vbldMacroTemporary).Add "TEST_DATETIME", "%DATETIME%" Note: using .Add will ensure the macro exists with the value specified, creating if necessary Kevin |
#3
|
|||
|
|||
Quote:
This works though: Application.Macros(vbldProject).Add strMacroName, Application.Macros(vbldSystem).Item("DATETIME").Va lue Cheers, Sam. |
#4
|
|||
|
|||
Text within brackets in a VBP step field indicates a script expression to be evaluated. So [DATETIME] evaluates to nothing in VBScript and [DATE] evaluates to the VBScript Date function (which btw will evaluate to the same value as the VBP DATE system macro).
Values between percents in a field indicate the name of a macro to be evaluated. So %DATE% or %DATETIME% will return the corresponding system macro values for those macros. This applies for all fields on most step properties (including the Script code field of the Run Script action). However, brackets and percent do not have any special meaning in the Script Editor (project scripts, global scripts, etc.), so you would need to use the method you described, or if the macro/script may itself reference other macros or script use: Application.ExpandMacrosAndScript("%DATETIME%") |
|
|