Reference/!define: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with "=!define = [/ifndef | /redef] ([/date|/utcdate] gflag [value]) | (/math gflag val1 OP val2) | (/file gflag filename.txt) This command will add gflag to the global define li...")
 
(Added StrFTime Format a time string rules)
Line 18: Line 18:
!define /file BUNCHASTUFF somesourcefile.cpp
!define /file BUNCHASTUFF somesourcefile.cpp
!define /redef USE_SOMETHING ${RESULT} ;redefine USE_SOMETHING</highlight-nsis>
!define /redef USE_SOMETHING ${RESULT} ;redefine USE_SOMETHING</highlight-nsis>
== strftime Format ==
Format a time string as per, [https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx MSDN strftime] rules.
<pre>
Code  Description
%A    Full weekday name
%b    Abbreviated month name
%B    Full month name
%c    Date and time representation appropriate for locale
%d    Day of month as decimal number (01 – 31)
%H    Hour in 24-hour format (00 – 23)
%I    Hour in 12-hour format (01 – 12)
%j    Day of year as decimal number (001 – 366)
%m    Month as decimal number (01 – 12)
%M    Minute as decimal number (00 – 59)
%p    Current locale's A.M./P.M. indicator for 12-hour clock
%S    Second as decimal number (00 – 59)
%U    Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w    Weekday as decimal number (0 – 6; Sunday is 0)
%W    Week of year as decimal number, with Monday as first day of week (00 – 53)
%x    Date representation for current locale
%X    Time representation for current locale
%y    Year without century, as decimal number (00 – 99)
%Y    Year with century, as decimal number
%z, %Z
      Either the time-zone name or time zone abbreviation, depending
      on registry settings; no characters if time zone is unknown
%%    Percent sign
</pre>

Revision as of 18:13, 30 May 2016

!define

[/ifndef | /redef] ([/date|/utcdate] gflag [value]) | (/math gflag val1 OP val2) | (/file gflag filename.txt)

This command will add gflag to the global define list. This will have a similar effect as using the /D switch on the command line (the define only becomes effective after the !define command).

If /date or /utcdate are used, value will be passed into strftime and the result will be used as the value of gflag. strftime converts special symbols into certain parts of the current time or date. For example, %H will be converted into the current hour in 24-hour format. For a complete list of available symbols, search for strftime on MSDN. On POSIX, you can get the list by using man strftime.

If /math is used, the result of 'val1 OP val2', where OP may be +,-,*,&,|,^,/ or % , will be used as the value of gflag. Note that val1 AND val2 MUST be integer values!

If /file is used, the entire text file specified (including whitespace and newlines) will be read and stuffed into gflag.

!define USE_SOMETHING
!define VERSION 1.2
!define /date NOW "%H:%M:%S %d %b, %Y"
!define /math RESULT 3 + 10
!define /math REST 15 % ${RESULT}
!define /file BUNCHASTUFF somesourcefile.cpp
!define /redef USE_SOMETHING ${RESULT} ;redefine USE_SOMETHING


strftime Format

Format a time string as per, MSDN strftime rules.

Code  Description

%A    Full weekday name
%b    Abbreviated month name
%B    Full month name
%c    Date and time representation appropriate for locale
%d    Day of month as decimal number (01 – 31)
%H    Hour in 24-hour format (00 – 23)
%I    Hour in 12-hour format (01 – 12)
%j    Day of year as decimal number (001 – 366)
%m    Month as decimal number (01 – 12)
%M    Minute as decimal number (00 – 59)
%p    Current locale's A.M./P.M. indicator for 12-hour clock
%S    Second as decimal number (00 – 59)
%U    Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w    Weekday as decimal number (0 – 6; Sunday is 0)
%W    Week of year as decimal number, with Monday as first day of week (00 – 53)
%x    Date representation for current locale
%X    Time representation for current locale
%y    Year without century, as decimal number (00 – 99)
%Y    Year with century, as decimal number
%z, %Z
      Either the time-zone name or time zone abbreviation, depending
      on registry settings; no characters if time zone is unknown
%%    Percent sign