GLBasic forum

Other languages => GLBasic - de => Topic started by: D2O on 2007-Mar-03

Title: Der Befehl STATIC ist super :)
Post by: D2O on 2007-Mar-03
Super Gernot das das STATIC gekommen ist,
damit kann man ansich Globale Variablen super Abkapseln.

Als Beispiel eine Frame Anzeige.
Voher:
Code (glbasic) Select
GLOBAL fps_time,fps_counter,fps,fps_temp


FUNCTION updatefps:
fps_time = GETTIMERALL()
fps_counter = fps_counter + 1
IF (fps_time-fps_temp)>1000
fps_temp = fps_time
fps = fps_counter
fps_counter = 0
ENDIF
       Return fps
ENDFUNCTION
Und jetzt mit STATIC ohne die "gefahr" der Globalen Variablen:
Code (glbasic) Select
FUNCTION getfps:

STATIC fps_time,fps_counter,fps,fps_temp
fps_time = GETTIMERALL()
fps_counter = fps_counter + 1
IF (fps_time-fps_temp)>1000
fps_temp = fps_time
fps = fps_counter
fps_counter = 0
ENDIF

RETURN fps
ENDFUNCTION
Danke
Title: Der Befehl STATIC ist super :)
Post by: Schranz0r on 2007-Mar-21
Ja ist ne schöne sache das ;)
Title: Der Befehl STATIC ist super :)
Post by: trucidare on 2007-Mar-22
find ich aucH ;)