Author Topic: Pre-set variables and extra date/time formats  (Read 4625 times)

omega9380

  • Guest
Pre-set variables and extra date/time formats
« on: December 02, 2016, 02:33:15 PM »
A nice feature to be added would be a small list of pre-set variables.  For example, a variable called {PRE:Today} that returns today's date would save us having to set a variable in every command to get the date or time.

Also, extra formats for outputting the date/time would be cool.  One of my VA profiles outputs information to a log file.  Right now that log gets named "December 2, 2016.log".  I'm working on a text file displayer proggie to view these logs in real time and I'm having problems with the spaces and commas in the filename.  Adding different options to the "Set Date/Time variable" function for the format for the returned date/time info would be awesome.  It might be as simple as adding an option to the "Set Date/Time" function that allows the use of strftime coding for the output.

Just my 2 cents!  Thanks!


EDIT by Pfeil: Automatic zero padding can be done using the "{DATETIMEFORMAT:}" token; Documentation for the formatting options can be found here: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
« Last Edit: April 18, 2020, 07:40:44 AM by Pfeil »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: Pre-set variables and extra date/time formats
« Reply #1 on: December 02, 2016, 05:45:47 PM »
A nice feature to be added would be a small list of pre-set variables.

Quote from: VoiceAttack Documentation
{TIME}-The current time, expressed in a 24-hour clock.
{TIME:dateVariableName}-The indicated date variable's time, expressed in a 24-hour clock.
{time}-The current time, expressed as a 12-hour clock.
{time:dateVariableName}-The indicated date variable's time, expressed as a 12-hour clock.
{TIMEHOUR}-The hour of the current time, expressed in a 12-hour clock.
{TIMEHOUR:dateVariableName}-The hour of the indicated date variable's time, expressed in a 12-hour clock.
{TIMEHOUR24}-The hour of the current time, expressed in a 24-hour clock.
{TIMEHOUR24:dateVariableName}-The hour of the indicated date variable's time, expressed in a 24-hour clock.
{TIMEMINUTE}-The minute of the current time.
{TIMEMINUTE:dateVariableName}-The minute of the indicated date variable's time.
{TIMESECOND}-The second of the current time.
{TIMESECOND:dateVariableName}-The second of the indicated date variable's time.
{TIMEMILLISECOND}-The second of the current time.
{TIMEMILLISECOND:dateVariableName}-The second of the indicated date variable's time.
{TIMEAMPM}-The AM/PM designation of the current time (or the proper designation of AM/PM in the set culture).
{TIMEAMPM:dateVariableName}-The AM/PM designation of the indicated date variable's time (or the proper designation of AM/PM in the set culture).
{DATE}-The current date, formatted as follows: 'April 3, 2015'.
{DATE:dateVariableName} -The indicated date variable, formatted as follows: 'April 3, 2015'.
{DATEYEAR}-The current year as a number (2015, 2016, 2017, etc).
{DATEYEAR:dateVariableName}-The indicated date variable's year as a number (2015, 2016, 2017, etc.).
{DATEDAY}-The current day of the month as a number.
{DATEDAY:dateVariableName}-The indicated date variable's day of the month as a
number.
{DATEMONTH}-The current month, spelled out ('April', 'May', 'June', etc.).
{DATEMONTH:dateVariableName}-The indicated date variable's month, spelled out ('April', 'May', 'June', etc.).
{DATEMONTHNUMERIC}-The current month as a number (April would be 4, May would be 5, June would be 6, etc.).
{DATEMONTHNUMERIC:dateVariableName}-The indicated date variable's month as a number (April would be 4, May would be 5, June would be 6, etc.).
{DATEDAYOFWEEK}-The current day of the week spelled out ('Monday', 'Tuesday', 'Wednesday', etc.).
{DATEDAYOFWEEK:dateVariableName}-The indicated date variable's day of the week spelled out ('Monday', 'Tuesday', 'Wednesday', etc.).
{DATETICKS}–The current date as ticks.  This will be a numeric value expressed as text that can be used for comparison.
{DATETICKS:dateVariableName}–The indicated date variable as ticks.  This will be a numeric value expressed as text that can be used for comparison.

The documentation can be found in your VoiceAttack install directory, in the file "VoiceAttackHelp.pdf".

omega9380

  • Guest
Re: Pre-set variables and extra date/time formats
« Reply #2 on: December 08, 2016, 02:57:34 PM »
Kewl, I missed that in the VA documentation.  One minor feature however would be leading zeroes on the date and time stamps.  eg when the value is less than 10, add a 0 to the number, as in 01, 02, 03.  Just a small request.  Thanks!!!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: Pre-set variables and extra date/time formats
« Reply #3 on: December 08, 2016, 03:14:41 PM »
If you need leading zeroes immediately, you can "assemble" the datestamp you want and have them added:
Code: [Select]
Write '[Blue] The current date is {DATEYEAR}-{EXP: IIF({DATEMONTHNUMERIC} < 10,0,'')}{DATEMONTHNUMERIC}-{EXP: IIF({DATEDAY} < 10,0,'')}{DATEDAY}' to log
The above will print the current date in an ISO 8601 compliant format, which includes leading zeroes.