HP3000-L Archives

August 2005, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Vance, Jeff H (Cupertino)" <[log in to unmask]>
Reply To:
Vance, Jeff H (Cupertino)
Date:
Tue, 16 Aug 2005 10:24:51 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (46 lines)
The quoted solution won't provide the leading zeros you'll need for
single digit hour and minutes. Paul C. has a correct solution, but also
consider the HPHHMMSSMMM variable. Enter :help hphhmmssmmm for more
info. 

This should work:
  setvar newtime hphhmmssmmm
  setvar newtime lft(newtime,2)+":"+str(newtime,3,2)

Note: the above is preferred to this:
  setvar newtime lft(hphhmmssmmm,2)+":"+str(hphhmmssmmm,3,2)

because it is possible that the minutes roll over to the next hour in
the middle of your setvar. For example: 
  setvar newtime lft(hphhmmssmmm,2)+":"+str(hphhmmssmmm,3,2)

Step 1: extract lft(hphhmmssmmm,2)   and you get, say, '08'
Step 2: extract str(hphhmmssmmm,3,2) and you get, say, '00' but at this
instant hphour has rolled to '09'.
Step 3: assign newtime '08:00' but it should be '08:59' or '09:00',
hence you have an ~ 1 hour error.

If you need to use hphour + hpminute then you still should (IMO) deal
with rolled over minutes. E.g.:
  setvar hh hphour
  setvar mm hpminute
  if hh <> hphour then
     setvar hh hphour
  endif
  setvar newtime rht('0!hh',2)+":"+rht('0!mm',2)
  

HTH,
 Jeff Vance, vCSY

...
> Setvar newtime  '!HPHOUR:!HPMINUTE'
...
> The problem I'm trying to solve is to pass a formatted 
> time to another process via the hphour and hpminute vars.  
> For instance hphour = 6 and hpminute = 10, so the formatted 
> string to pass would be 06:10.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2