POV-Ray : Newsgroups : povray.newusers : Returning values from macros : Re: Returning values from macros Server Time
2 May 2024 21:31:55 EDT (-0400)
  Re: Returning values from macros  
From: clipka
Date: 3 Jun 2016 08:27:50
Message: <575177c6$1@news.povray.org>
Am 03.06.2016 um 03:37 schrieb Bald Eagle:
> With respect to scope,
> 
> I have a variable that I declare locally:
> 
> #local Steps = ....
> 
> I tried to:
> 
> #declare Steps = Steps;
> 
> and then use Steps outside of the macro - "undeclared identifier"   :(
> 
> I can't "hand-off" a local value to a global identifier of the same name?
> or "redefine a local variable as a global variable" ?

POV-Ray 3.7 indeed provides no way to assign a value to a global
variable if there already exists a variable with the same name at any
"more local" scope.

However, POV-Ray 3.7.1 will introduce a mechanism to specifically access
identifiers at the global scope, allowing you to achieve the desired
effect using the following syntax:

    #declare global(Steps) = Steps;

The `global(IDENTIFIER)` pseudo-function will be available wherever the
"bare" identifier could be used, and will cause any local identifiers of
the same name to be ignored when resolving the identifier.

There will also be a corresponding `local(IDENTIFIER)` pseudo-function
to specifically access identifiers at the "most local" scope, causing
identifiers at any "less local" scope to be ignored.

This functionality is already available in the current development releases.


Post a reply to this message

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