FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour An addition to Tget Class - METHOD ScrollTime( nDirection)
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM

An addition to Tget Class - METHOD ScrollTime( nDirection)

Posted: 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 (fw): Select all Collapse
//----------------------------------------------------------------------------//
* 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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

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

Posted: Mon Jun 14, 2010 07:49 AM

Ramesh,

Many thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM

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

Posted: Mon Jun 14, 2010 09:41 AM

Dear Mr.Antonio,

This is our FWH. No thanks please.

Warm regards,

  • Ramesh Babu P

Continue the discussion