Page 1 of 1

How replace Delay()

Posted: Mon Jun 10, 2019 2:14 pm
by munfraid
Hello everybody, this is maybe a true beginners question. In PB I could easily have blinking text using Delay().
Code: Select all
OpenWindow(0,0,0,600,400,"Test", #PB_Window_ScreenCentered)

TextGadget(0, 10, 10, 580, 40, "This is a text")

SetGadgetText(0, "")
Delay(200)
SetGadgetText(0, "This is a test")
Delay(200)
SetGadgetText(0, "")
Delay(200)
SetGadgetText(0, "This is a test")
Delay(200)
SetGadgetText(0, "")
Delay(200)
SetGadgetText(0, "This is a test")


How this can be achieved in SB?

Re: How replace Delay()

Posted: Mon Jun 10, 2019 2:47 pm
by Peter
There is no Delay() in JavaScript. Use AddWindowTimer() instead.

Code: Select all
#Window = 0
#TextGadget = 0
#Timer = 0

Procedure TimerEvent()
 
  If GetGadgetText(#TextGadget)=""
    SetGadgetText(#TextGadget, "This is a text")
  Else
    SetGadgetText(#TextGadget, "")
  EndIf
 
EndProcedure

OpenWindow(#Window, 0, 0, 300, 260, "Timer example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

TextGadget(#TextGadget, 10, 10, 280, 30, "This is a text")

AddWindowTimer(#Window, #Timer, 1000)

BindEvent(#PB_Event_Timer, @TimerEvent())


Greetings ... Peter

Re: How replace Delay()

Posted: Mon Jun 10, 2019 3:09 pm
by munfraid
Ah, I see.. I think I understood this now. Thanks a lot, Peter! :D