Type Problem
Blitz3D Forums/Blitz3D Beginners Area/Type Problem
| ||
Does anyone see a problem with this code:If B\MOUSE_OVER=True If MOUSE_X >= B\BX And MOUSE_X <= B\BX+B\WIDTH If MOUSE_Y >= B\BY And MOUSE_Y <= B\BY+B\HEIGHT If KeyHit(N)=True B\SNAP=True EndIf If KeyHit(DELETE_KEY)=True Delete B EndIf If B\SNAP=False Rect B\BX,B\BY,B\WIDTH,B\HEIGHT,1 Else Rect B\BGX,B\BGY,B\WIDTH,B\HEIGHT,1 EndIf EndIf EndIf EndIf Whenever I try to delete the type B I get a 'MAV" error.. |
| ||
The following line "IF B\Snap=false" is causing you the error. You should either delete the type instance 'B' last, or set a flag to delete the instance and do so at the end of your loop When it gets to the line " if B\snap=false " b no longer exists. |
| ||
Makes sense, thanks! |
| ||
If your thinking of deleting types with lots of if's, then:If b\x = 5 then delete b ElseIf b\y = 6 then delete b end if instead of If b\x = 5 then delete b End If If b\y = 6 then delete b end if The first one will not produce the error, the second one however will. |
| ||
How about this?If b\x = 5 or b\y = 6 delete b end if |
| ||
Even shorter is: If b\x = 5 Or b\y = 6 Then Delete b Pentium4 3.2Ghz, 1GB RAM, nVidia GeForce 6800 256MB, SB Audigy ZS |
| ||
@subirenihil Show off! LOL |