System Variables

Many task fields support variable entries.  The program has system variables that you can use in these task fields.

Using variables in text fields
The variable must be formatted as:  $%Variable_Name::Option1::Option2..%$
Options may only be required by some Variables.
Examples: $%DATE::hh:mm:yy%$ or $%USERNAME%$

Nested Variables
Single level nested variables are allowed using the format
$%....NEST-[nested_variable]-NESTEND...%$
examples :
1) $%FILE::DATE::pp-dd-YY_mm-hh-ss::NEST-fileMon::FilePath-NESTEND%$ gets the date modified time for the file path found in the variable 'fileMon::FilePath'.
2) $%FILE::DATE::pp-dd-YY_mm-hh-ss::c:\test\NEST-fileMon::FileName-NESTEND%$ gets the date modified time for the file found in the variable 'fileMon::FileName'.

Only 1 nested variable can be read in a single field.

The following is the list of System Variables

* DATE
You can specify the current date using the following format
$%DATE::dd/pp/yy hh:mm:ss AMPM%$

You can also choose any date, time, or date/time separators like /, _, -, or :  etc...

YY = 4-digit year will be output (2001 etc..)
yy = 2-digit year will be output (00-99)
pp = 2-digit month will be output (01-12)
ppx = 1-digit or 2-digit month will be output(1-12)
qqq = 3-character month will be output (jan-dec)
QQQ = 3-character month will be output (JAN-DEC)
Qqq = 3-character month will be output (Jan-Dec)
dd = 2-digit date will be output (01-31)
ddx = 1-digit or 2-digit date will be output(1-31)
HH = 2-digit hour based on 12 hour clock will be output (01-12) (should generally be used with am_pm)
HHx = 1-digit or 2-digit hour based on 12 hour clock will be output(1-12)
hh = 2-digit hour based on 24 hour clock will be output  (00-23)
hhx = 1-digit or 2-digit hour based on 24 hour clock will be output  (0-23)
mm = 2-digit minute will be output (00-59)
mmx = 1-digit or 2-digit minute will be output (0-59)
ss = 2-digit seconds will be output (00-59)
am_pm = AM is output for AM hours, PM is output for PM hours
wy = 2-digit week of the year
wyx = 1-digit or 2-digit week of the year
dy = 3-digit day of the year
dyx = 1-digit, 2-digit, or 3-digit day of the year
dw = day of the week (1-7)  (country dependent, ex: 1 = sunday in the US,  and 1 = monday in France)
wm = week of the month (1-5)
dwm = day of week in the month  (1-5)

Examples: (for date/time = June 21st, 2005, 3:45:30 PM)
$%DATE::dd-pp-YY%$   =   21-06-2005
$%DATE::dd-pp1-yy%$   =   21-6-05
$%DATE::qqq/dd/yy_hh:mm:ss%$   =   jun/21/05_15:45:30
$%DATE::Qqq dd, YY, HH:mm am_pm%$   =   Jun 21, 2005, 03:45 PM

 

* DATES
This variable is provided as a simpler option to the DATE variable above and it also provides more flexibility.
The DATES variable is described here.

 

* DATEADD
This variable returns the value of a single time field (date, hour, minute etc..), after adding (or subtracting) days/hours etc.. from the current time:
$%DATEADD::dd::X%$
where X is the number to add.  For next day, use 1, for previous day/hr etc.. use -1.

Examples: (for date/time = June 21st, 2005, 3:45:30 PM)
$%DATEADD::dd::1%$  = 22
$%DATEADD::dd::-1%$ = 20
$%DATEADD::hh::1%$  = 16
$%DATEADD::hh::-1%$ = 14
$%DATEADD::mm::1%$  = 46
$%DATEADD::mm::-1%$ = 44

Notes:
1) You can only add or subtract and recieve one field at a time
2) Only numerical date / time values are supported. i.e. days of week (Mon., Tue. etc..) or months (jan., feb. etc.. ) are not supported.
3) You cannot embed a DATEADD variable within a DATE variable.  You have to use all variables in sequence.
Example:  If you want current month and date, but require previous hour, in the format month-date_hr, you would use
$%DATE::pp-dd_%$$%DATEADD::hh::-1%$ = 06-21_14

 

* DATEADDX
This variable returns a formatted date/time string, after adding (or subtracting) days/hours etc. from the current time:
$%DATEADDX::Format::dd::X%$
where X is the number to add.  For next day/hour etc., use 1, for previous day/hour etc.. use -1. Format is the date/time format that you need the result to be returned in.

This variable allows user to add date/hour/minute to current time intelligently. Ex: adding a day to 12/31/03, rolls over to 01/01/04, not to 12/32/03

Examples: (for date/time = June 21st, 2005, 3:45:30 PM)
$%DATEADDX::YY-pp-dd::dd::1%$  = 2004-06-22
$%DATEADDX::YY-pp-dd_hh-mm::hh::-1%$ = 2004-06-21_14-45
$%DATEADDX::YY-pp-dd_hh-mm::hh::1%$  = 2004-06-21_16-45
$%DATEADDX::YY-pp-dd_hh-mm::mm::1%$  = 2004-06-21_16-46
$%DATEADDX::YY-pp-dd_hh-mm::mm::-1%$ = 2004-06-21_16-44

Notes:
1) Only the following are allowed in the 3rd field: YY, pp, dd, hh, mm
2) You can only add or subtract one field at a time
3) Only numerical date / time values are supported. i.e. days of week (mon., tue. etc..) or months (jan., feb. etc.. ) are not supported.

 

* DATEMONTH
This variable allows you to get the last day of the previous month, or first Sunday of next month etc.. It returns a formatted date/time string. The format required is:
$%DATEMONTH::format::month_offset::day_val::X%$
format is the date/time format that you need the result to be returned in
month_offset = 0 for current month, 1 for next month, -1 for previous month
day_val = sun, mon, tue, wed, thu, fri, sat to specify day of week. Use 'day' to specify date of the month.
X = week of month (1-5) or day of month (1-31). To specify the last week of the month, use -1. To specify the last date of the month, use -1.

Examples: (for month = April, 2004)
To get first Sunday of this month:
$% DATEMONTH::YY-Qqq-dd::0::sun::1%$  = 2004-Apr-04
To get last Sunday of this month:
$% DATEMONTH::YY-Qqq-dd::0::sun::-1%$  = 2004-Apr-25
To get first Monday of next month:
$% DATEMONTH::YY-Qqq-dd::1::mon::1%$  = 2004-May-03
To get last Monday of previous month:
$% DATEMONTH::YY-Qqq-dd::-1::mon::-1%$  = 2004-Mar-29
To get last day of previous month:
$% DATEMONTH::YY-Qqq-dd::-1::day::-1%$  = 2004-Mar-31

 

* FILE
This variable outputs information on file size, date or can parse lines from the file into the variable.  This is useful if you need to monitor files for certain strings etc..  This variable can be used in the 'File Variable' task to process text in files, and output results to new files.

$%FILE::SIZE::[file_path]%$
$%FILE::DATE::[format]::[file_path]%$
$%FILE::LINE::FIRST::[file_path]%$
$%FILE::LINE::LAST::[file_path]%$
$%FILE::LINE::MID::[start_line]::[end_line]::[file_path]%$
$%FILE::LINECONTAINS::FIRST::[string]::[file_path]%$
$%FILE::LINECONTAINS::LAST::[string]::[file_path]%$
$%FILE::LINECONTAINS::ALL::[string]::[file_path]%$
$%FILE::LINENUMCONTAINS::FIRST::[string]::[file_path]%$
$%FILE::LINENUMCONTAINS::LAST::[string]::[file_path]%$
$%FILE::LINESAFTER::FIRST/LAST::[string]::[offset]::[file_path]%$
$%FILE::LINESBEFORE::FIRST/LAST::[string]::[offset]::[file_path]%$

Examples:
1) $%FILE::SIZE::c:\temp\test.txt%$
will output the size of the file in bytes

2) $%FILE::DATE::qqq-dd-yy_hh:mm:ss::c:\temp\test.txt%$
will output the last modified time of the file, in the date/time format you specify.  Please see the DATE variable above, for details on how to format the date.  example:  if June 21,2002, 3:45 pm was the last modified time of the file c:\temp\test.txt, this variable will output: jun-21-02_15:45:30

3) $%FILE::LINE::FIRST::c:\temp\test.txt%$
will output the first line in the file c:\temp\test.txt

4) $%FILE::LINE::LAST::c:\temp\test.txt%$
will output the last line in the file c:\temp\test.txt

4) $%FILE::LINE::MID::5::90::c:\temp\test.txt%$
will output the lines 5-90 in the file c:\temp\test.txt.  If there are only 65 lines in the file, it will output lines 5-65.

6) $%FILE::LINECONTAINS::FIRST::error alert::c:\temp\test.txt%$
will output the first line in test.txt, that contains the string 'error alert'.  It will return an empty string, if the 'error alert' is not found.

7) $%FILE::LINECONTAINS::LAST::error alert::c:\temp\test.txt%$
will output the last line in test.txt, that contains the string 'error alert'.  It will return an empty string, if the 'error alert' is not found.

8) $%FILE::LINECONTAINS::ALL::error alert::c:\temp\test.txt%$
will output all the lines in test.txt, that contains the string 'error alert'.  It will return an empty string, if the 'error alert' is not found in any line.

9) $%FILE::LINENUMCONTAINS::FIRST::error alert::c:\temp\test.txt%$
This variable will output the line number of the first line, that contains the string 'error alert'.  It will return 1000000, if the string is not found.

10) $%FILE::LINENUMCONTAINS::LAST::error alert::c:\temp\test.txt%$
This variable will output the line number of the last line, that contains the string 'error alert'.  It will return 1000000, if the string is not found.

11) $$%FILE::LINESAFTER::FIRST/LAST::[string]::[offset]::[file_path]%$
This variable will output all lines, after the line that contains the String [string] .
Use FIRST to output all lines, after the first line containing the [string]
Use LAST to output all lines, after the last line containing the [string]
use [offset] = 0 , to include the line containing the [string], use [offset] = 1, to start at next line, etc..
examples:
$$%FILE::LINESAFTER::FIRST::error::0::c:\temp\test.txt%$  (will include the line containing the string 'error')
$$%FILE::LINESAFTER::LAST::error::1::c:\temp\test.txt%$   (will not include the line containing the string 'error')

12) $$%FILE::LINESBEFORE::FIRST/LAST::[string]::[offset]::[file_path]%$
This variable will output all lines, before the line that contains the String [string] .
Use FIRST to output all lines, before the first line containing the [string]
Use LAST to output all lines, before the last line containing the [string]
use [offset] = 0 , to include the line containing the [string], use [offset] = 1, to end at previous line, etc..
examples:
$$%FILE::LINESBEFORE::FIRST::error::0::c:\temp\test.txt%$   (will include the line containing the string 'error')
$$%FILE::LINESBEFORE::LAST::error::1::c:\temp\test.txt%$    (will not include the line containing the string 'error')


 

* Other Variables

USERNAME
This variable outputs the value of the current user
example: if your username is 'john'
$%USERNAME%$   =john

USERHOME
This variable outputs the value of the current users home directory
example: if your username is 'john', your home directory on win 2000 would be
$%USERHOME%$   =c:\documents and settings\users\john

TEMPDIR
This variable outputs the current value of the temp folder
$%TEMPDIR%$   =c:\temp

OSNAME
This variable outputs name of the operating system
example: on Windows 2000
$%OSNAME%$   =Windows 2000

OSVERSION
This variable outputs the version of the operating system
example: on Windows 2000
$%OSVERSION%$   =5.0

IPADDRESS
This variable outputs the computers IP address
example: if your systems IP address is 192.168.0.1
$%IPADDRESS%$   =192.168.0.1

SYSNAME
This variable outputs the computer name on the network
example: if your computer name is Win1
$%SYSNAME%$   =Win1