POV-Ray : Newsgroups : povray.general : Array in function. Not, but... : Array in function. Not, but... Server Time
21 Jun 2024 10:09:53 EDT (-0400)
  Array in function. Not, but...  
From: ingo
Date: 14 Apr 2021 13:50:14
Message: <XnsAD0CC9CB8C256seed7@news.povray.org>
As we can't use arrays inside functions I tried something else. A spline 
is an array, kind of and works in functions. So some test code, that 
works. There's one little thing I don't realy understand. I have to undef 
the 'i' used in SPL or rename it or the one in N. Otherwise I get: 

line xxx: Parse Error: Local variable name expected!

#declare arrSPL = array[5]{
#declare SPL = spline{
    i, arrSPL[i],
#debug concat(str(SPL(4).x,5,5),"\n")
#undef arrSPL
#undef i      // <--------- !!

#declare Ar = function{
#debug concat(str(Ar(4).x,5,5),"\n")
#undef SPL

#declare N = function(D){sum(i, 0, D, Ar(i).x)};
#declare NAR = N(4);
#debug concat(str(NAR,5,5),"\n")


Post a reply to this message

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