Der Befehl STATIC ist super :)

Previous topic - Next topic

D2O

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
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

Schranz0r

Ja ist ne schöne sache das ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

trucidare

MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC