POV-Ray : Newsgroups : povray.advanced-users : Using arrays in functions : Re: Using arrays in functions Server Time
28 Sep 2024 06:13:48 EDT (-0400)
  Re: Using arrays in functions  
From: clipka
Date: 17 Mar 2011 05:49:59
Message: <4d81d947$1@news.povray.org>
Am 16.03.2011 17:07, schrieb Trevor G Quayle:
> I want to use an array inside a function, for example:
>
> function(x,y,z){MYARRAY[][]}
>
> I can hard code an array index, and it is fine:
>
> eg.  function(x,y,z){MYARRAY[2][3]}
>
> , however I can't create an array index from a function.  I get an error "Float
> expected but vector or color expression found"
>
> e.g. function(x,y,z){MYARRAY[max(min(int(x),9),0)][max(min(int(y),9),0)]}

Note that inside a function declaration, any and all variables (except 
for references to the function parameters) are evaluated at parse time; 
this is also true for array variables. But at parse time the function 
parameters x and y are unknown for obvious reasons.

BTW, evaluation of the variables is delegated to the general SDL parser, 
not the specialized function syntax parser; therefore in your case x and 
y are interpreted as the respective axis vectors rather than the 
function parameters.


Post a reply to this message

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