POV-Ray : Newsgroups : povray.bugreports : String parameters in macros do not return value Server Time
22 Nov 2024 14:36:01 EST (-0500)
  String parameters in macros do not return value (Message 1 to 3 of 3)  
From: Samuel van Egmond
Subject: String parameters in macros do not return value
Date: 1 Jun 1999 17:24:31
Message: <3754417f.0@news.povray.org>
I can't get string parameters to return a value.  I'm pretty sure I should
be able to do this.  See code for the example:

// Example start

#macro TestString(String)
    // This line should change the parameter, it does not, it only changes
the local value !!!
    #declare String = "Bye Now!"
#end

#macro TestFloat(Float)
    // This line changes the parameter as expected.
    #declare Float = 123.4;
#end

// Works as expected
#local MyFloat = 5;
TestFloat(MyFloat)
#debug str(MyFloat,1,1)

// Does not work as expected
#local MyString = "Hello"
TestString(MyString)
#debug MyString
#debug "\n"

sphere {1,1}   // So the engine doesn't complain...

// Example end

Output is:
123.4Hello

Should be:
123.4Bye Now!

I work on Windows NT on the standard binaries.


Post a reply to this message

From: Nieminen Mika
Subject: Re: String parameters in macros do not return value
Date: 2 Jun 1999 10:39:15
Message: <37553403.0@news.povray.org>
Samuel van Egmond <sam### [at] infabcom> wrote:
: #macro TestString(String)
:     #declare String = "Bye Now!"
: #end

: #local MyString = "Hello"
: TestString(MyString)
: #debug MyString

  A workaround could be:

#macro TestString()
    "Bye Now!"
#end

#local MyString = TestString()
#debug MyString

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Samuel van Egmond
Subject: Re: String parameters in macros do not return value
Date: 2 Jun 1999 17:07:52
Message: <37558f18.0@news.povray.org>
Hi,

thanks, but this was just the simple version, I tried to use this in a
recursive macro where the string parameter gets 'eaten' one character at the
time.  I've already got a work around by not using a parameter but a global
#declare.  Just thought I'd better put in a bug report so others would not
spend the same time figuring out why their macro doesn't work.

   [ ][ ][ ]         [ ][ ][ ]      [ ]         [ ]
[ ]               [ ]         [ ]   [ ][ ]   [ ][ ]
   [ ][ ][ ]      [ ][ ][ ][ ][ ]   [ ]   [ ]   [ ]
            [ ]   [ ]         [ ]   [ ]         [ ]
   [ ][ ][ ]      [ ]         [ ]   [ ]         [ ]  ;-)

Nieminen Mika wrote in message <37553403.0@news.povray.org>...
>Samuel van Egmond <sam### [at] infabcom> wrote:
>: #macro TestString(String)
>:     #declare String = "Bye Now!"
>: #end
>
>: #local MyString = "Hello"
>: TestString(MyString)
>: #debug MyString
>
>  A workaround could be:
>
>#macro TestString()
>    "Bye Now!"
>#end
>
>#local MyString = TestString()
>#debug MyString
>
>--
>main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
>):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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