POV-Ray : Newsgroups : povray.advanced-users : Using arrays in functions : Re: Using arrays in functions Server Time
27 Jun 2024 14:15:28 EDT (-0400)
  Re: Using arrays in functions  
From: Trevor G Quayle
Date: 17 Mar 2011 09:45:01
Message: <web.4d820f56b19991f81c811d20@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> 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.

I figured as much and was hoping for a direct workaround that I was missing.
Regardless, I have found an alternate solution that suits my current
requirements.


-tgq


Post a reply to this message

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