Here is some working code for Fanuc Macro B with pretty good comments.
Code:
N0010 (DATE CODE)
(DATE SOURCE = #3011 IN YYYYMMDD FORMAT)
(TIME SOURCE = #3012 IN HHMMSS FORMAT)
(4 DIGIT YEAR = #1)
(YEAR TENS DIGIT = #2)
(YEAR ONES DIGIT = #3)
(MONTH = #4)
(DAY = #5)
(DAYS THIS YEAR = #6)
(DAYS HUNDREDS DIGIT = #7)
(DAYS TENS DIGIT = #8)
(DAYS ONES DIGIT = #10)
(TEMP = #12)
(HOUR TENS DIGIT = #13)
(HOUR ONES DIGIT = #14)
N0020
(YEAR)
#1 = FIX[#3011 / 10000.] (4 DIGIT YEAR)
#2 = FIX[[#1 - 2000.] / 10.](YEAR TENS DIGIT)
#3 = FIX[[#1 - 2000.] - [#2 * 10.]](YEAR ONES DIGIT)
(MONTH)
#4 = FIX[[#3011 - [#1 * 10000.]] / 100.]
(DAY)
#5 = #3011 - [#1 * 10000.] - [#4 * 100.]
(HOUR)
#13 = FIX[#3012 / 100000.] (HOUR TENS DIGIT)
#14 = FIX[[#3012 / 10000.] - [#13 * 10]] (HOUR ONES DIGIT)
N0030(ARRAY TO COUNT DAYS)
#6 = #5 (DAYS IN CURRENT MONTH)
IF [#4 LE 1.] GOTO 40
#6 = #6 + 31. (DAYS IN JANUARY)
IF [#4 LE 2.] GOTO 40
N0032(DAYS IN FEBRUARY CHECK FOR LEAP YEAR)
#12 = [[#1 / 4.] - FIX[#1 / 4.]]
#6 = #6 + 28. (FEB. HAS 28 DAYS)
IF [#12 EQ 0] THEN #6 = #6 + 1. (LEAP YEAR FEB. HAS 29 DAYS)
IF [#4 LE 3.] GOTO 40
#6 = #6 + 31. (DAYS IN MARCH)
IF [#4 LE 4.] GOTO 40
#6 = #6 + 30. (DAYS IN APRIL)
IF [#4 LE 5.] GOTO 40
#6 = #6 + 31. (DAYS IN MAY)
IF [#4 LE 6.] GOTO 40
#6 = #6 + 30. (DAYS IN JUNE)
IF [#4 LE 7.] GOTO 40
#6 = #6 + 31. (DAYS IN JULY)
IF [#4 LE 8.] GOTO 40
#6 = #6 + 31. (DAYS IN AUGUST)
IF [#4 LE 9.] GOTO 40
#6 = #6 + 30. (DAYS IN SEPTEMBER)
IF [#4 LE 10.] GOTO 40
#6 = #6 + 31. (DAYS IN OCTOBER)
IF [#4 LE 11.] GOTO 40
#6 = #6 + 30. (DAYS IN NOVEMBER)
N0040
(SPLIT DIGITS FOR DAYS)
#7 = FIX[#6 / 100.] (DAYS HUNDREDS DIGIT)
#8 = FIX[[#6 - [#7 * 100.]] / 10.] (DAYS TENS DIGIT)
#10 = FIX[#6 - [#7 * 100.] - [#8 * 10.]] (DAYS ONES DIGIT)
Mazak should use the same variables with one exception. It uses a 2 digit year format. (well check your machine) so you may have to modify that part.
Date and time (Year-month-day and hour-minute-second)
Variables numbered 3011 and 3012 can be used to read date and time data.
Variable Nos. Description
#3011 Date (Year-month-day)
#3012 Time (Hour-minute-second)
Example: If the date is December 15, 1995 and the time is 16:45:10, data is set as follows in
the corresponding system variables:
#3011 = 951215
#3012 = 164510
Also I saw the option to turn off exponential display of macro numbers
Go to the macro variable page, and mouse up to the "Setup" drop down window. Click the "Not Exponential Display" option.