POV-Ray : Newsgroups : povray.general : arrays.inc - Rand_Array_Item() trouble : Re: arrays.inc - Rand_Array_Item() trouble Server Time
1 Aug 2024 04:11:40 EDT (-0400)
  Re: arrays.inc - Rand_Array_Item() trouble  
From: ingo
Date: 13 Apr 2006 12:06:06
Message: <Xns97A4B8241CED2seed7@news.povray.org>
in news:web.443d560fde047fad6c4803960@news.povray.org Trevor G Quayle 
wrote:

> also, the macro could be rearranged to keep the error check as:
> 

#macro Rand_Array_Item(Array, Stream)
   #if(dimensions(Array)=1)
      #local Return = Array[floor(rand(Stream)*0.9999999*dimension_size
(Array,1))];
   #else
      #error "The Rand_Array_Item() macro only works for 1D arrays."
   #end
   Return
#end

I've ran so often into this problem that I use the above more or less as 
a standard solution now.

I wouldn't mind if a #return statement became part of the SDL in a 
(near) future version. And for the error handling a #try #except #else 
#finally would also be nice for a (not so near) future version.

Ingo


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.