Just used your new version, it works now. Thanks a lot for your help.

There is only one little change:
   ....
   def rand(max = 0)
     ....

Thx,
Daniel