POV-Ray : Newsgroups : povray.newusers : Returning values from macros : Re: Returning values from macros Server Time
26 Apr 2024 09:01:30 EDT (-0400)
  Re: Returning values from macros  
From: Cousin Ricky
Date: 30 May 2016 12:20:00
Message: <web.574c67d776b80bcd71c9a5f20@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Could someone please post a small, simple macro that results in a scalar, a
> vector, and an array getting passed "out" to the global SDL world?

You can pass them back through the macro arguments by declaring the formal
parameters with the final results.  For example:

  #macro MyMacro (S, V, A)
    #declare S = 1;
    #declare V = <2, 3, 4>;
    #declare A = array[5]
    #for (I, 0, 4)
      #declare A[I] = pow (I, 2);
    #end
  #end

The argument identifiers would need to be declared with dummy values before
passing them to the macro.

Be careful with this technique.  It is frowned upon in structured programming,
but without heterogeneous data structure capability, POV-Ray SDL leaves you
little choice.


Post a reply to this message

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