POV-Ray : Newsgroups : povray.beta-test : [doc] concat with one parameter : Re: [doc] concat with one parameter Server Time
29 Jul 2024 10:20:49 EDT (-0400)
  Re: [doc] concat with one parameter  
From: Felix Wiemann
Date: 21 May 2002 11:07:48
Message: <3cea62c4@news.povray.org>
Warp wrote:
>   I don't understand why you can't give the value directly.

If the string is modified inside the macro but the original string is 
needed after execution, it's necessary to use concat. For example:


#macro M(S)
        #debug "\n"  // linefeed
        #debug S     // "POV-Ray"
        #debug "\n"
        #declare S = substr(S, 5, 3)  // S = "Ray"
        #debug S     // "Ray"
        #debug "\n"
        #end

#declare S = "POV-Ray"
M(concat(S))
#debug substr(S, 1, 3)  // "POV" or "Ray"


The output is:

POV-Ray
Ray
POV

but if you change M(concat(S)) to M(S) the output is:

POV-Ray
Ray
Ray

-- 
Felix Wiemann


Post a reply to this message

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