POV-Ray : Newsgroups : povray.newusers : Returning values from macros Server Time
31 Oct 2024 18:58:05 EDT (-0400)
  Returning values from macros (Message 11 to 20 of 24)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 4 Messages >>>
From: Cousin Ricky
Subject: Re: Returning values from macros
Date: 30 May 2016 18:35:00
Message: <web.574cbf2e76b80bcd71c9a5f20@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I also found this rope macro, but the referenced link doesn't wind up getting
> displayed properly in my browser (Chrome) - it looks like the source HTML, with
> all of the tags visible, and not properly formatted as HTML.   Does anyone else
> have this problem?
>
> http://lib.povray.org/collection/rope/chrisb%201.0/rope.html

The <style> element is indeed in the wrong place, but that's not why you're not
getting the images.  A few years ago, the Object Collection server was
reconfigured to serve the user manuals as plain text, for security reasons.
You'll get the same result for all HTML user manuals from the Collection.

If you download the entire module, your local copy of the user manual will
render properly in your Web browser.

If you download *only* the HTML file and view it locally, your browser will
style it as HTML.  However, the images will be missing.  You can hotlink the
images by editing the HTML file using a plain text editor, and inserting

  <base href="http://lib.povray.org/collection/rope/chrisb%201.0/">

into the <head> section.  Please note that hotlinking is normally considered
extremely bad manners, but in this case, you're just loading images that would
have been served anyway.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Returning values from macros
Date: 31 May 2016 03:01:12
Message: <574d36b8@news.povray.org>
On 30-5-2016 15:40, Bald Eagle wrote:
>
> I'm playing with some power transmission towers that I decided to cobble
> together.
>
> No idea why - they just suddenly captured my interest, and a recent post about
> catenary curves seemed to fuel my need to play with power lines in POV-Ray.
>

Immediately the pylon code comes to my mind. From an unknown author. See 
attached. I have used it in a couple of scenes.



-- 
Thomas


Post a reply to this message


Attachments:
Download 'danger.gif' (4 KB) Download 'danger.png' (2 KB) Download 'utf-8' (2 KB) Download 'utf-8' (20 KB)

Preview of image 'danger.gif'
danger.gif

Preview of image 'danger.png'
danger.png

From: clipka
Subject: Re: Returning values from macros
Date: 31 May 2016 12:32:34
Message: <574dbca2$1@news.povray.org>
Am 30.05.2016 um 15:40 schrieb Bald Eagle:

> 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?

Up to (and including) POV-Ray 3.7.0, you could use the approach
mentioned by Cousin Ricky:

    // the macro;
    // note that this macro does not actually "return" anything,
    // but has the side effect of redefining whatever variables
    // are passed as parameters
    #macro MyMacro (SomeScalar, SomeVector, SomeArray)
      // overwrite the parameters' values
      #declare SomeScalar = 4711;
      #declare SomeVector = <1,2,3>;
      #declare SomeArray = array[12];
      #local I = 0;
      #while (I < 12)
        #declare SomeArray[I] = ...;
        #local I = I + 1;
      #end
    #end

    // initialize the variables;
    // note that the types do not have to match,
    // but the variables need to be defined,
    // for rather obscure technical reasons:
    #declare MyScalar = false;
    #declare MyVector = false;
    #declare MyArray  = false;

    // call the macro, which will set the variables
    // to new values:
    MyMacro(MyScalar, MyVector, MyArray);


The current POV-Ray 3.7.1-alpha provides an alternative by making use of
a new syntax extension dubbed "tuple-style assigment":

    // the macro;
    // note that this does not take any parameters,
    // and instead "returns" the right-hand side for a
    // tuple-style assignment
    #macro MyMacro()
      #local SomeScalar = 4711;
      #local SomeVector = <1,2,3>;
      #local SomeArray = array[12];
      #local I = 0;
      #while (I < 12)
        #declare SomeArray[I] = ...;
        #local I = I + 1;
      #end
      // return all the values
      (SomeScalar, SomeVector, SomeArray)
    #end

    // invoke the macro to generate the right-hand side
    // for a tuple-style assignment;
    // note that the variables do _not_ have to be
    // defined beforehand:
    #declare (MyScalar, MyVector, MyArray) = MyMacro();

(It should be noted that this syntax extension does /not/ really add
tuple support to the SDL; all it does is provide a way to bundle
multiple assignments in such a way that the values for the entire batch
can be generated by a single macro invocation.)


Post a reply to this message

From: Bald Eagle
Subject: Re: Returning values from macros
Date: 31 May 2016 13:05:00
Message: <web.574dc43176b80bcdb488d9aa0@news.povray.org>
OK, I think I'm wrapping my head around this, finally, again.

Just curious - will there be mixed data-type support in arrays, if there are
tuple-style tricks?

Having arrays where different rows could be of different data types - scalars,
strings, vectors, whatever...   would be VERY handy.

Pipe-dream here, but:
Would you be able to have an array of faux-tuples?

I'll have to check out 3.7.1-alpha - that would help me work out what I'm
envisioning without having to struggle too much with 3.7-vanilla

Thanks as always!


Post a reply to this message

From: clipka
Subject: Re: Returning values from macros
Date: 31 May 2016 15:25:08
Message: <574de514$1@news.povray.org>
Am 31.05.2016 um 19:04 schrieb Bald Eagle:

> Just curious - will there be mixed data-type support in arrays, if there are
> tuple-style tricks?
> 
> Having arrays where different rows could be of different data types - scalars,
> strings, vectors, whatever...   would be VERY handy.
> 
> Pipe-dream here, but:
> Would you be able to have an array of faux-tuples?

Nope, nope and nope.

Tuple-/style/ /assignments/ it is, nothing more.

Implementing any other tuple-style tricks will be a PITA, thanks to the
clusterfuck we occasionally call a parser.


Post a reply to this message

From: Doctor John
Subject: Re: Returning values from macros
Date: 31 May 2016 17:16:49
Message: <574dff41$1@news.povray.org>
On 31/05/16 20:24, clipka wrote:
> 
> Tuple-/style/ /assignments/ it is, nothing more.
> 
> Implementing any other tuple-style tricks will be a PITA, thanks to the
> clusterfuck we occasionally call a parser.
> 

... and there was me thinking that you were going to rewrite it ;-)

John
-- 
Protect the Earth
It was not given to you by your parents
You hold it in trust for your children


Post a reply to this message

From: Bald Eagle
Subject: Re: Returning values from macros
Date: 31 May 2016 17:55:01
Message: <web.574e07fc76b80bcd5e7df57c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Nope, nope and nope.
>
> Tuple-/style/ /assignments/ it is, nothing more.
>
> Implementing any other tuple-style tricks will be a PITA, thanks to the
> clusterfuck we occasionally call a parser.

I honestly get the impression that you're holding something back from us.  I
think that as someone who works so closely with the source code and inner
workings of POV-Ray, you ought to open up and tell us how you really feel.

I mean, if you've got something to say, just say it.  All this waffling and
couching things in layer upon layer of politically correct phraseology makes it
looks as if you're hiding something.






























:D


Post a reply to this message

From: Stephen
Subject: Re: Returning values from macros
Date: 31 May 2016 18:27:49
Message: <574e0fe5$1@news.povray.org>
On 5/31/2016 10:54 PM, Bald Eagle wrote:
> clipka <ano### [at] anonymousorg> wrote:
>
>> Nope, nope and nope.
>>
>> Tuple-/style/ /assignments/ it is, nothing more.
>>
>> Implementing any other tuple-style tricks will be a PITA, thanks to the
>> clusterfuck we occasionally call a parser.
>
> I honestly get the impression that you're holding something back from us.


Yes, don't beat about the bush.
We are all big boys here*. We can handle it. :)

*Unless Janet is lurking.


-- 

Regards
     Stephen


Post a reply to this message

From: clipka
Subject: Re: Returning values from macros
Date: 1 Jun 2016 01:57:39
Message: <574e7953@news.povray.org>
Am 31.05.2016 um 23:54 schrieb Bald Eagle:

>> Implementing any other tuple-style tricks will be a PITA, thanks to the
>> clusterfuck we occasionally call a parser.
> 
> I honestly get the impression that you're holding something back from us.  I
> think that as someone who works so closely with the source code and inner
> workings of POV-Ray, you ought to open up and tell us how you really feel.
> 
> I mean, if you've got something to say, just say it.  All this waffling and
> couching things in layer upon layer of politically correct phraseology makes it
> looks as if you're hiding something.

:)


Post a reply to this message

From: Bald Eagle
Subject: Re: Returning values from macros
Date: 2 Jun 2016 21:40:06
Message: <web.5750df7576b80bcd5e7df57c0@news.povray.org>
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" ?


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 4 Messages >>>

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