POV-Ray : Newsgroups : povray.general : Function: Problem in Defining Server Time
23 Apr 2024 10:20:23 EDT (-0400)
  Function: Problem in Defining (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Sven Littkowski
Subject: Re: Function: Problem in Defining
Date: 6 Apr 2018 07:13:58
Message: <5ac75676$1@news.povray.org>
Using RRand now, testing. Looks good.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: Function: Problem in Defining
Date: 6 Apr 2018 07:16:20
Message: <5ac75704$1@news.povray.org>
I just did not know about the existence of that include. But such is
life: you never stop to discover or learn new things. :-)

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: Function: Problem in Defining
Date: 6 Apr 2018 07:17:14
Message: <5ac7573a$1@news.povray.org>
Yes, I already found it that. I opened that include file, and saw the
parameter for the SEED item.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: clipka
Subject: Re: Function: Problem in Defining
Date: 6 Apr 2018 12:06:45
Message: <5ac79b15$1@news.povray.org>
Am 06.04.2018 um 03:02 schrieb dick balaska:
> On 04/05/2018 12:21 PM, clipka wrote:
> 
>>      #declare MySeed = seed(4711);
>>      #macro MyRand(Min,Max)
>>        // compute stuff
>>        #local Rand = rand(MySeed);
>>        #local Result = Min + (Max-Min)*Rand;
>>        // "return" the computed value
>>        Result
>>      #end
>>
> 
> I wrap the return value in parenthesis. The intent is a little clearer
> in the macro def and may avoid usage problems.
> 
>     // "return" the computed value
>     (Result)

You run into problems with this approach if you ever want to return
something that isn't a scalar or vector. For instance, the following
won't fly:

    #macro FullName(FileName)
      #local Result = concat("C:/Fnord/", FileName);
      (Result)
    #end

    #include FullName("stuff.inc")


> I know clipka, legally this is not required, because Result is a single
> number. But I tend to do
> 
>     #local V=<1,2,3>;
>     // "return" the computed value
>     (Result+V)
> 
> where it is morally (debuggingly?) required.

Then maybe don't do that ;)

I really literally use `Result` as the local variable name, and make
sure to always store the very end result in there, for the same purpose
that you use the parentheses. That way

    Result

is guaranteed to be the only thing the macro "emits". Solves the same
problem as your parentheses, but has the added benefit of working in
more scenarios.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Function: Problem in Defining
Date: 7 Apr 2018 02:47:35
Message: <5ac86987$1@news.povray.org>
On 6-4-2018 13:16, Sven Littkowski wrote:
> I just did not know about the existence of that include. But such is
> life: you never stop to discover or learn new things. :-)
> 

I cannot believe this! :-O

I would urgently ask you to look at the POV-Ray folders! You pretend you 
have been using POV-Ray for over /ten/ years and you /never ever/ looked 
into the include?!? the Insert Menu?!? the scenes?!? folders; not to 
speak of the documentation. I begin to understand the background of some 
of your questions...

-- 
Thomas


Post a reply to this message

From: Sven Littkowski
Subject: Re: Function: Problem in Defining
Date: 7 Apr 2018 21:46:11
Message: <5ac97463$1@news.povray.org>
Well, of course I have looked at files inside the INCLUDE folder many,
many times, but each time I checked only on some specific names, mostly
when i ran into some problems. Can't change it.

I actually use POV-Ray since 1990 or so...   :-D

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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