Just starting out? Need help? Post your questions and find answers here.
munfraid
 
Posts: 30
Joined: Sat Mar 24, 2018 1:33 pm

How replace Delay()

by munfraid Mon Jun 10, 2019 2:14 pm

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?
User avatar
Peter
 
Posts: 625
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: How replace Delay()

by Peter Mon Jun 10, 2019 2:47 pm

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
munfraid
 
Posts: 30
Joined: Sat Mar 24, 2018 1:33 pm

Re: How replace Delay()

by munfraid Mon Jun 10, 2019 3:09 pm

Ah, I see.. I think I understood this now. Thanks a lot, Peter! :D
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 7 guests