POV-Ray : Newsgroups : povray.general : Macros and Arrays : Re: Macros and Arrays Server Time
29 Jul 2024 20:24:33 EDT (-0400)
  Re: Macros and Arrays  
From: John VanSickle
Date: 18 Sep 2010 05:29:03
Message: <4c94865f$1@news.povray.org>
On 9/16/2010 1:39 PM, lkreinitz wrote:
> Would anyone know why this doesn't work
>
> #macro AtIndex( A , I )
>    #if ( dimension_size(I,1) = dimensions(A) )
>      A[
>      #local ii = 0;
>      #while ( ii<  dimensions(A) )
>        #if (ii>  0 )
>          ][
>        #end
>        I[ii]
>        #local ii = ii + 1;
>      #end
> // uncomment ';' to avoid error
>      ]  // ;
>    #else
>      #error "Dimension Mismatch"
>    #end
> #end

You appear to be trying to access a member of an array with any number
of dimensions using the members of another array as the indices.  Why
do you need a general-purpose solution for this?  Your array access 
should be tailored to the specific array you are using, and accessing 
should not be left up to a macro.

> I thought that all the macro was doing was substituting new symbols
> There are work arounds ( Assigning after declaring etc. )
> but It's kind of annoying.

Yes, the macros are primarily symbol-substitution, but there comes a 
point at which parsing starts without further substitution.  If your 
intended expression is not fully built at that point, there will be 
problems.

Remember that the purpose of the scene description language is to 
describe the scene you want to render.  It is not intended to be a 
general-purpose programming language.

Regards,
John


Post a reply to this message

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