How to do Digits-to-integer, and EDT to EST
November 8, 2013
What is the MPE/iX system command to convert a string of digits into an integer value? I find NUMERIC will tell me if I have a string of digits, and DECIMAL converts a number to a string, but I cannot locate the reciprocal function.
Donna Hofmeister of Allegro responds:
It's actually easier than you think to change a string variable into a numeric one. Here's an example, with some blah-blah-blah to go with it.
: setvar foo "123" <--- string with all-number content
: echo ![typeof(foo)] <--- do ': help typeof ' to find out what '2' means
2
: echo ![numeric(foo)] <--- if you have any doubt about the 'quality' of the content use numeric
TRUE
: setvar foo_n !foo <--- here's the conversion
: echo ![typeof(foo_n)] <--- and a test for giggles
1
My HP 3000 system was still on EDT, so I wanted to change it during startup. I answered "N" to the date/time setting at end of startup, and it refused my entry of 11/04/13; it returned a question mark. After several quick CR, it set the clock back to 1 Jan 85, which is where it is now waiting.
Gilles Schipper of GSA responds:
While the system is up and running, you could try (while the system is up and running):
:setclock ;date=mm/dd/yyyy;time=hh:mm
:setclock ;cancel
:setclock ;timezone=w5:00 (for example)
:setclock ;cancel (again)
I'd been quite surprised by how many small 'single machine' shops don't properly set the hardware clock to GMT with the software clock offset by 'timezone' Instead, they have their hardware and software clock set to the same time, use the 'setclock correction=' and then give either a +3600 or -3600, for spring or fall time changes.
Allegro's got a simple command file called FIXCLOCK, on their Free Allegro Software page, that allows fixing the hardware clock AND properly setting the time-offset for the software clock -- all without having to take the system down.
Here's the spring and fall time change jobstream code. You can use this and modify it for your specific needs. Note that it's set up for the Eastern US time zone. (That's the TIMEZONE = W5:00 -- meaning the number of hours different than GMT -- and TIMEZONE = W4:00 lines.) Modify these lines as necessary for your timezone.
!JOB TIMECHG,MANAGER/user-passwd.SYS/acct-passwd;hipri;PRI=CS;OUTCLASS=,1
!
!setvar Sunday, 1
!
!setvar March, 3
!setvar November, 11
!
!showclock
!if hpday = Sunday and &
! hpmonth = November and &
! hpdate < 8 then
! comment (first Sunday of November)
! SETCLOCK TIMEZONE = W5:00
! TELLOP ********************************************
! TELLOP Changing the system clock to STANDARD TIME.
! TELLOP The clock will S L O W D O W N until
! TELLOP we have fallen back one hour.
! TELLOP ********************************************
!elseif hpday = Sunday and &
! hpmonth = March and &
! hpdate > 7 and hpdate < 15 then
! comment (second Sunday of March)
! SETCLOCK TIMEZONE = W4:00
! TELLOP *********************************************
! TELLOP Changing the system clock to DAYLIGHT SAVINGS
! TELLOP TIME. The clock jumped ahead one hour.
! TELLOP *********************************************
!else
! comment (no changes today!)
! TELLOP *********************************************
! TELLOP No Standard/Daylight Savings Time Chgs Req'd
! TELLOP *********************************************
!endif
!
!comment - to avoid 'looping' on fast CPU's pause long enough for
!comment - local clock time to be > 2:00a, even in fall...
!while hphour = 2 and hpminute = 0
! TELLOP Pausing 1 minute... waiting to pass 2am
! TELLOP Current Date/Time: !HPDATEF - !HPTIMEF
! showtime
! pause 60
!endwhile
!
!stream timechg.jcl.sys;day=sunday;at=02:00
!showclock
!EOJ
Do a showclock to confirm results. Careful, though, of any existing running jobs or sessions that may be clock-dependent.