I did read it and i did test it. But still it has nothing to do with the Dir() function and its ability to set @error

Code:

$var = 0
$username = dir("c:\*.*")
While $var < 10 and not @Error
'var = '+ $var ?
$var = $var + 1
If $var = 5
MessageBox("snookered","Test")
EndIf
$userName = dir()
Loop
? @error

_________________________
Eric