Problem with incrementation

Just starting out? Need help? Post your questions and find answers here.
User avatar
Ar-S
Posts: 7
Joined: Tue Feb 25, 2014 5:27 pm

Problem with incrementation

Post by Ar-S »

Hello, i'm using SB 2 demo.
I'm trying to convert a pure basic program but i have a problem to add +1 to some values with a timer. I do not understand why.

thanks for helping.

Code: Select all


Declare TimerEvents()
Declare GO()

Global Launch, NbrDes, Count

;- INIT
  NbrDes = 3
  Launch = #True
  Count = 0
  ;--------
  
Procedure TimerEvents()
  Protected X, Count

  If Launch = #True
    Count+1

    X + 128
    ;- TEST -----------------------
    Debug "X : " + X
    Debug "Count : " + Count
    ;- EndTest ---------------------
    
    If Count = NbrDes
      X = 0
      Count = 0
      Launch = #False
      Debug "This is the end, my only friend, the end."
    EndIf
    
  EndIf
EndProcedure


Procedure GO()

  OpenWindow(0, #PB_Ignore, #PB_Ignore, 128*3, 128+50,"Virtual Dices",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  AddWindowTimer(0,1,300)

  BindEvent(#PB_Event_Timer, @TimerEvents(),0)

EndProcedure



GO()
~ Ar-S ~ - PB User - SB User
My Website : Dépannage Informatique dans l'Aude (11)
UnOfficial PB ressources : http://forumpb.ldvmultimedia.com/index.php
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Problem with incrementation

Post by Fred »

May be you should not protect the 'count' variable

Code: Select all

Protected X, Count
User avatar
Ar-S
Posts: 7
Joined: Tue Feb 25, 2014 5:27 pm

Re: Problem with incrementation

Post by Ar-S »

:oops: OK thanks
~ Ar-S ~ - PB User - SB User
My Website : Dépannage Informatique dans l'Aude (11)
UnOfficial PB ressources : http://forumpb.ldvmultimedia.com/index.php
Post Reply