Navigation:  Commands and Procedures > Predefined Macros >

System Macros

Previous pageReturn to chapter overviewNext page

Visual Build Professional provides the following predefined system macros and tools.  Windows also defines some of these macros as environment variables, which will take precedence over Visual Build Pro's definition (if enabled on the General application options page), and you can override these values by defining your own project or global macros or environment variables.  Some values vary depending on the current date/time, project, or step being processed:

 

DATE: Inserts the current date.  The date will be formatted according to the Short Date style in the Control Panel Regional Settings for dates.

 

DATETIME: Inserts the current date and time.  The value will be formatted according to the Short Date and Time styles in the Control Panel Regional Settings for dates.

 

Note: Script code can also be used to insert date values with specific formatting.  For instance, to insert the date in the format YYYY-MM-DD, use the VBScript expression [Year(Now) & "-" & Month(Now) & "-" & Day(Now)] in any step field.  See the scripting function reference on MSDN for more details.  System scripts for formatting dates are also provided.

 

DOSCMD: Executes an operating system command (i.e., DIR, COPY, ECHO, etc.), batch file, or command script.  Under Windows 2000/XP, this executes CMD.EXE.  Use this in a Run Program action to execute batch files, command scripts, individual shell commands, or to execute a program under the command shell for redirection (> or >>) or piping (|) of that program's output.

 

COMPUTERNAME: The current computer name.

 

FAILSTEP_STATUS: Holds the build status of the project step that failed, can be used in Failure steps to log the actual failed step info.

 

FAILSTEP_OUTPUT: Contains the output from the failed step.

 

FAILSTEP_NAME: Contains the name of the failed step (the script expression FailedStep.Name).

 

LASTSTEP_STATUS: Holds the build status of the last step that was processed.

 

LASTSTEP_OUTPUT: Contains any output from the last step that was processed (even if the step's Disable logging option is checked).  This can be useful for parsing the output for error information in the following step or the step's vbld_StepDone script event.

 

LASTSTEP_NAME: Contains the name of the last step that was processed (the script expression LastStep.Name).

 

LOGFILE: The filename of the log file (an empty string if logging is not enabled).  This will be the setting configuration in Application Options; it can also be overridden by a global, project, or temporary LOGFILE macro.

 

PROCFILES_FULLPATH: The full path and filename of the current file for the Process Files action.

 

PROJDIR: The full path of the open Visual Build Pro project file.  Useful for accessing other files that will be located relative to the project, allowing projects to work correctly no matter which drive or root directory they are placed at on a particular machine.

 

PROJFILE: The full path and filename of the open project file.

 

PROJROOT: The root name of the project file without extension.

 

QUOTE_STR: Ensures that a string has double quotes around it.

 

READ_INI: A macro used to read a value from an INI file and use in a step field.  The syntax for calling it is: %READ_INI(filename, section, valuename, [default])%.  Filename must be the full drive+path+filename for the file.

 

READ_XML: A macro to read an element or attribute from an XML file and use in a build step. The syntax for calling it is: %READ_XML(filename, xpath[, default][, namespaces])%.  xpath denotes an XPath expression to search for; the text of the first matching node is returned or a blank string if not found.    namespaces specifies one or more namespaces aliases separated by spaces (i.e., xmlns:bk='book' xmlns:n='http://testuri').  See the XML.bld sample for more details.

 

Note: This macro requires MSXML version 3.0 or later to be installed.

 

REG_READ: A macro to read a value from the registry and use in a build step. The syntax for calling it is: %REG_READ("hive\key\value", ["default"])%.  If an empty value is provided for the default parameter and the value is not found, an error occurs.  To read the default value of a key, use an ending backslash character (i.e., %REG_READ("HKEY_CURRENT_USER\Software\Test\Key\",)%).  To read value names containing backslashes, use a double-backslash to delimit the key/value (i.e., %REG_READ("HKEY_CURRENT_USER\Software\Test\\Value\Name",)% would read a value named 'Value\Name').  See the RegEdit.bld sample for more details.

 

TEMP: The temporary path.

 

TOOLSDIR: The location of built-in Visual Build Pro and miscellaneous third-party tools (usually C:\Program Files\VisBuildPro6\Tools).

 

TRIM_QUOTES: Strips any double quotes surrounding a string value.

 

USERNAME: The logged on user's username.

 

VISBUILD: The full path to the current instance of Visual Build Pro.  Use to build another project from the current project (see the Chain.bld sample).

 

VISBUILD_CONFIG_DIR: The path to load Visual Build Pro application and action data from.

 

VISBUILDDIR: The path and filename of the current instance of Visual Build Pro.

 

VISBUILDVER: The version of the current instance of Visual Build Pro.

 

WINDIR:  The Windows directory.

 

WINSYSDIR: The Windows System directory.