Page 1 of 1

TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 7:38 am
by Silvio.Falconi
Dear Antonio,
Not run

on tled class I insert on new method
if ! Empty( ::oWnd:hWnd )
::Create()
::Default()
::oWnd:AddControl( Self )
else
::oWnd:DefControl( Self )
endif

IF ::lBlink
DEFINE TIMER ::oTmr INTERVAL ::nInterval ACTION ::Blink() OF self
Endif


on Paint method at the init I Insert

IF ::lBlink
IF !::oTmr=NIL
::lStatus:=.t.
::oTmr:Activate()
ENDIF
ENDIF


and this is the blink method

METHOD Blink() CLASS TLED

Local nOpen:= ::nColorLedON
Local nClose:= ::nColorLedOFF

if ::lStatus
::nColorLedON := nClose
else
::nColorLedON := nOpen
endif

::Refresh()

::lStatus := ! ::lStatus

return NIL



I saw when the timer in active the color is before 8388608 and the is nil and it continue

I insert at init on Paint method this line :
::nColorLedON := IIF (::lBlink,::Blink(),::nColorLedON)
It seem to run but the when the lstatus is .f. it not put the right color but NIL
and ::oTmr is allways NIL

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 8:06 am
by Antonio Linares
Silvio,

In your code, Activate the timer right after creating it:

DEFINE TIMER ...

ACTIVATE TIMER ...

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 8:28 am
by Silvio.Falconi
I modify on New method
IF ::lBlink
DEFINE TIMER ::oTmr INTERVAL ::nInterval ACTION ::Blink() OF self
ACTIVATE TIMER ::oTmr
ENDIF

but not run also

the procedure not activate the time and not change the colors of Leds

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 8:44 am
by Silvio.Falconi
...

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 9:56 am
by Silvio.Falconi
I modify now:
DATA oOut READONLY
DATA nTime READONLY AS NUMERIC INIT 0
METHOD Initiate( hDlg ) INLINE Super:Initiate( hDlg ), ::Default()

on New method
if ! Empty( ::oWnd:hWnd )
::Create()
::oWnd:AddControl( Self )
else
::oWnd:DefControl( Self )
endif

on Default method
IF ::lBlink
DEFINE TIMER ::oOut INTERVAL ::nInterval OF ::oWnd ACTION ( ::nTime ++,::Blink())
ACTIVATE TIMER ::oOut
ENDIF


Now on interval change the color but then not return that was before!!

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 10:14 am
by Antonio Linares
Silvio,

If you don't know how to fix your code, post your class source code here and we will test it.

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 10:34 am
by Silvio.Falconi
ok , but I wish finish it . on myself then, as I sad to you in private mail, I can publish the class.

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 10:57 am
by Antonio Linares
Silvio,

if you plan to share it, why don't you share it now so others can help you ?

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 12:32 pm
by fafi
Hello..

If you don't mind please test this..

Thank you
Best Regards
Fafi

Code: Select all  Expand view

#include "fivewin.ch"

static oTimer, oSay , lOn, oSay1, oSay2

function Main()
 
  lOn := .f.
 
  define dialog oDlg from 1,1 to 200,200 pixel
 
  define timer oTimer interval 500 action Blinker(oDlg)
 
  @10,10 say oSay prompt "Blink" size 30,12 of oDlg pixel
 
  @30,10 say oSay1 prompt "(^-^)" size 30,12 of oDlg pixel
 
  @30,10 say oSay2 prompt "____" size 30,12 of oDlg pixel
 
 
  activate DIALOG oDlg CENTERED on init ( oTimer:hWndOwner := oDlg:hWnd, oTimer:Activate() )
 

return nil


static function Blinker(oDlg)

oTimer:deactivate()

if lOn
   oSay:Hide()
   oSay1:Hide()
   oSay2:Show()
else
   oSay:Show()
   oSay2:Hide()
   oSay1:Show()
endif

oDlg:cTitle := time()

lOn := !lOn

oTimer:activate()

return nil

 

Re: TO ANTONIO HELP FOR BLINK

PostPosted: Tue May 28, 2013 5:40 pm
by Silvio.Falconi
I resolved antonio