I think this version of Phaelax's code works slightly better:
set display mode desktop width(), desktop height(), 32
sync on : sync rate 60 : sync
autocam off
position camera 0, 100, -400
point camera 0, 0, 0
load dll "c:\windows\system32\user32.dll", 1
clickDelay = call dll(1,"GetDoubleClickTime")
make object cube 1, 100
clicks = 0
clickStamp = 0
Do
if mouseclick() = 1 and mflag = 0
mflag = 1
inc clicks
clickStamp = timer()
endif
if mouseclick() = 0 and clicks <> 2 then mflag = 0
T = timer()
if clickStamp + clickDelay < timer() then clicks = 0
if clicks = 2
if object exist(1) then delete object 1
endif
set cursor 0,0
print clicks
sync
loop
The original version allowed me to continually increment the number of clicks recorded which I assumed wasn't intended

.