An addition to Tget Class - METHOD ScrollTime( nDirection)

An addition to Tget Class - METHOD ScrollTime( nDirection)

Postby RAMESHBABU » Sun Jun 13, 2010 11:49 am

Hi Friends,

I was in need of this method like ScrollDate method in TGet Class and I have put little effort on this.

If anybody feels that this is useful, they can make use of it by adding an additional method in TGet Class :

METHOD ScrollTime( nDirection ) under METHOD ScrollDate(nDirection)

Regards,

- Ramesh Babu P

Code: Select all  Expand view

//----------------------------------------------------------------------------//
* Method Added by RAMESH BABU P on 13-06-2010
METHOD ScrollTime( nDirection ) CLASS TGet

   LOCAL cFormat, cType
   LOCAL cTime
   LOCAL nHours, nMinutes, nSeconds, nPos

   #ifndef __XPP__
      cTime := ::Value
   #else
      cTime := ::VarGet()
   #endif

   nPos     := ::nPos
   cFormat  := Set( _SET_TIMEFORMAT, "hh:mm:ss")
   nHours   := VAL(SUBSTR(cTime,1,2))
   nMinutes := VAL(SUBSTR(cTime,4,2))
   nSeconds := VAL(SUBSTR(cTime,7,2))
   cType    := Upper( Substr( cFormat, nPos, 1 ) )

   If ! cType $ "HMS" .and. nPos > 1
      cType = Upper( Substr( cFormat, nPos - 1, 1 ) )
   Endif

   do case
   case nPos <= 2
      nHours += nDirection
      If nHours >24 .OR. nHours < 0
         nHours := 0
         nMinutes := 0
         nSeconds := 0
      Endif

      cTime := StrZero( nHours, 2 ) + ":" + StrZero( nMinutes, 2 ) + ":" + StrZero( nSeconds, 2 )
   case nPos >3 .AND. nPos <= 5
      nMinutes += nDirection
      if nMinutes > 59
         nHours   += 1
         nMinutes := 0
      Elseif nMinutes < 0
         nMinutes := 59
         nHours   -= 1
         If nHours < 0
            nHours := 0
            nMinutes := 0
            nSeconds := 0
         Endif      
      Endif  
      cTime := StrZero( nHours, 2 ) + ":" + StrZero( nMinutes, 2 ) + ":" + StrZero( nSeconds, 2 )
      If Empty( cTime )
         cTime := "00:00:00"
      Endif
   case nPos >6 .AND. nPos <= 8
      nSeconds += nDirection
      If nSeconds > 59
         nSeconds := 0
         nMinutes += 1
         If nMinutes >59
            nMinutes := 0
            nHours += 1
         Endif
      Elseif nSeconds < 0
         nSeconds := 59
         nMinutes -= 1
         If nMinutes < 0
            nHours -= 1
            nMinutes := 59
         Endif
         If nHours < 0
            nHours := 0
            nMinutes := 0
            nSeconds := 0
         Endif      
      Endif
      cTime := StrZero( nHours, 2 ) + ":" + StrZero( nMinutes, 2 ) + ":" + StrZero( nSeconds, 2 )
   endcase

   Set( _SET_TIMEFORMAT, cFormat )

   if nDirection > 0
      if ::bMax != NIL .and. cTime > Eval( ::bMax )
         MessageBeep()
      else
         ::cText( cTime )
      endif
   else
      if ::bMin != NIL .and. cTime < Eval( ::bMin )
         MessageBeep()
      else
         ::cText( cTime )
      endif
   endif

#ifndef __CLIPPER__
   do case
   case cType == "H"
      ::SetSel( 0, 2 )
   case cType == "M"
      ::SetSel( 3, 5 )
      ::nPos := 5
   case cType == "S"
      ::SetSel( 6, 8 )
      ::nPos := Len(cTime) - 1
   end case
#else
   ::SetPos( nPos )
#endif

RETURN nil
 
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: An addition to Tget Class - METHOD ScrollTime( nDirection)

Postby Antonio Linares » Mon Jun 14, 2010 7:49 am

Ramesh,

Many thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: An addition to Tget Class - METHOD ScrollTime( nDirection)

Postby RAMESHBABU » Mon Jun 14, 2010 9:41 am

Dear Mr.Antonio,

This is our FWH. No thanks please.

Warm regards,

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Marc Venken and 88 guests