|
|
"How Camp" <hac### [at] gmailcom> wrote in message
news:web.443d3793c13db847429e56f30@news.povray.org...
>
> I'm sure this is something silly. Test1 works fine, but the line just
> prior
> to Test2 complains that I don't have a ';' at the end of my #declare
> statement
> (which I do). What am I doing wrong? Can anyone give a simple working
> example of Rand_Array_Item() for me?
>
>
> #include "arrays.inc"
> #declare MyArray = array[5] {0, 1, 2, 3, 4};
> #declare RS = seed(12345);
> #debug concat("Test1: ", str(Rand_Array_Item(MyArray,RS),0,0), "\n")
> #declare Test = Rand_Array_Item(MyArray,RS);
> #debug concat("Test2: ", str(Test,0,0), "\n")
>
>
> - How
>
Odd!...
If you convert the result returned from the macro call into a string before
assigning it to the variable it works.
Also if you copy the active ingredients from the Rand_Array_Item macro into
the source it works.
But if you assign the numeric result from the macro to a variable without
converting it to a string it complains.
Anyway, all of the following examples work.
Maybe someone else could offer an explanation as to why the one you have
doesn't, but I can't see any material difference.
#include "arrays.inc"
#declare MyArray = array[5] {0, 1, 2, 3, 4};
#declare RS = seed(12345);
#debug concat("Test1: ", str(Rand_Array_Item(MyArray,RS),0,0), "\n")
#declare Test = str(Rand_Array_Item(MyArray,RS),0,0);
#debug concat("Test2: ", Test, "\n")
#declare Test =
MyArray[floor(rand(RS)*0.9999999*dimension_size(MyArray,1))];
#debug concat("Test3: ", str(Test,0,0), "\n")
Regards,
Chris B.
Post a reply to this message
|
|