POV-Ray : Newsgroups : povray.newusers : How to use #Macro like a function ? : How to use #Macro like a function ? Server Time
5 Jul 2024 03:58:57 EDT (-0400)
  How to use #Macro like a function ?  
From: Gyscos
Date: 29 Jun 2010 14:35:00
Message: <web.4c2a3bf6d73f9cb9e3006550@news.povray.org>
Hi !

I would like to make some functions. But I found POV-Ray's functions very
limited : it seems it is not possible to use directives inside.
So I decided to use macro instead, since I want to use them once at parse time
only.

From what I had understood, the #macro works pretty much as if it replaced the
call with the content of the macro.

However, I'm trying to make macro that return a float value, so I tried
something like :

#macro MyMacro(arg)

  #if (arg > 1)
    5
  #else
    10
  #end

#end

But it doesn't work...
I saw some exemples like that :


#macro MyMacro(arg)

  #if (arg > 1)
    #declare X=5
  #else
    #declare X=10
  #end

#end

But it doesn't seem right, I don't like toying with global var from inside
functions like this, I feel like I could overwrite some previous val...

Is there a clean way to do this kind of things ?
Thanks :)


Post a reply to this message

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