is this a good idea or not?

Blitz3D Forums/Blitz3D Programming/is this a good idea or not?

Hi, I was wondering whether this use of SetEnv() / GetEnv() is safe or not:
Graphics 800,600,32,2
SeedRnd MilliSecs()
SetBuffer BackBuffer()

;variables
Global scrw = GraphicsWidth()
Global scrh = GraphicsHeight()
Global age = 10

Type bug
	Field x,y,n$,c
End Type

;setup

;main loop
While Not KeyHit(1)
Cls

Color 255,255,255
Rect 100,100,scrw-200,scrh-200,0

For b.bug = Each bug
	Color b\c,127+Sin(b\x*10)*127,127+Sin(b\y*10)*127
	Rect b\x-20,b\y-20,41,41,0
	Color 255,255,255
	Text b\x,b\y,b\n$,1,1
	b\x=b\x+Rnd(-5,5)
	b\y=b\y+Rnd(-5,5)
	If b\x<120 Then b\x=120
	If b\y<120 Then b\y=120
	If b\x>scrw-120 Then b\x=scrw-120
	If b\y>scrh-120 Then b\y=scrh-120
Next

Locate 0,0
Print "<Insert> to Make bug"
Print "<Delete> To kill bug"
If KeyHit(210) Then FlushKeys():makebug(Input("Make Name : ")):FlushKeys()
If KeyHit(211) Then FlushKeys():killbug(Input("Kill Name : ")):FlushKeys()

Flip
Wend
End

;functions
Function makebug(name$)
	If name$<>"" And Object.bug(GetEnv("bug_"+name$))=Null
		b.bug = New bug
		b\x = Rnd(100,scrw-100)
		b\y = Rnd(100,scrh-100)
		b\n$ = name$
		b\c = Rnd(0,255)
		SetEnv "bug_"+name$,Handle(b)
	EndIf
End Function

Function killbug(name$)
	b.bug = Object.bug(GetEnv("bug_"+name$))
	If b.bug <> Null
		Delete b
	EndIf
End Function
thanks

It's an interesting method of using a string identifier for a an array. I don't know if it is secure. Probably two Blitz apps would collide when running simultanously. Fact is, the Blitz Env Varliables are only there as long as your app is running.

Basicly you could use an ordinary string array to get the same, and simply parse the array to find a certain bug name. Physicly it would be the same amount of work for the computer since the bug name must be found anyway. I even guess it's faster when you do it directly within blitz. eg:
for i=0 to num_of_bugs
 if searched_bug$=bug$(i)
  ...
 endif
next


ok, thanks