POV-Ray : Newsgroups : povray.general : How to pass a string from the command line - help? Server Time
4 Nov 2024 17:36:27 EST (-0500)
  How to pass a string from the command line - help? (Message 1 to 7 of 7)  
From: Mathuin
Subject: How to pass a string from the command line - help?
Date: 1 Oct 2008 18:35:00
Message: <web.48e3fa9f79b5340cd8a103ef0@news.povray.org>
The canonical "hello world" scene file has the following components: includes,
camera, light source, a black-and-white checkered plane, and a shiny sphere
sitting on the plane.  I can create a template file "template.pov" that has
some of those components (includes, camera, light source) and a content file
"content.inc" with the others (plane, sphere).  This is easy enough for a
single template file and a single content file -- just replace the plane and
object with '#include "content.inc"' and put the plane and object in
"content.inc" and it just works.

Now what I really want to do is have "content.inc" and "othercontent.inc" and
"stillothercontent.inc" then modify the template to contain '#include Content'
and have the specific include file chosen via the command line something like
this:  povray -Itemplate.pov Declare=Content="content.inc"  Alas, the
command-line version of Declare appears to be limited to floats.  If I
absolutely have to change the #include line in the template to point at the
specific content I will, but that answer is not scalable.  Is there any other
way working from the command line that I can achieve this goal?  Thanks!


Post a reply to this message

From: Chris B
Subject: Re: How to pass a string from the command line - help?
Date: 2 Oct 2008 05:22:02
Message: <48e492ba$1@news.povray.org>
"Mathuin" <mat### [at] gmailcom> wrote in message 
news:web.48e3fa9f79b5340cd8a103ef0@news.povray.org...
> Now what I really want to do is have "content.inc" and "othercontent.inc" 
> and
> "stillothercontent.inc" then modify the template to contain '#include 
> Content'
> and have the specific include file chosen via the command line something 
> like
> this:  povray -Itemplate.pov Declare=Content="content.inc"  Alas, the
> command-line version of Declare appears to be limited to floats.

Three approaches immediately spring to mind.

1. Write a two line script that first writes the name of your include file 
into another include file then calls POV-Ray. For example, a DOS .bat file 
could be something like:

  echo #include "%1">contentwrapper.inc
  povray -Itemplate.pov ....

This would write an #include statement embedding the first parameter passed 
to the script into the file 'contentwrapper.inc' then it would invoke 
POV-Ray with your template.pov scene which would #include contentwrapper.inc 
which would, in turn, #include the nested file of your choice.

2. Use floats with an #if or #switch directive to select the #include file 
statement of your dreams.

3. Number your include files (e.g. content42.inc) and use the concat 
function within your #include statement e.g.

  #include concat("content",Content,".inc")

Regards,
Chris B.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: How to pass a string from the command line - help?
Date: 2 Oct 2008 06:47:51
Message: <48e4a6d7$1@news.povray.org>
Chris B wrote:
> 
> "Mathuin" <mat### [at] gmailcom> wrote in message 
> news:web.48e3fa9f79b5340cd8a103ef0@news.povray.org...
>> Now what I really want to do is have "content.inc" and 
>> "othercontent.inc" and
>> "stillothercontent.inc" then modify the template to contain '#include 
>> Content'
>> and have the specific include file chosen via the command line 
>> something like
>> this:  povray -Itemplate.pov Declare=Content="content.inc"  Alas, the
>> command-line version of Declare appears to be limited to floats.
> 
> Three approaches immediately spring to mind.

It is a lot easier than that:

Use the Include_Header / +HI command-line option. Documentation at 
http://www.povray.org/documentation/view/3.6.1/220/ .

	Thorsten


Post a reply to this message

From: Mathuin
Subject: Re: How to pass a string from the command line - help?
Date: 2 Oct 2008 08:20:00
Message: <web.48e4bc28b41ac224d8a103ef0@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> Chris B wrote:
> >
> > "Mathuin" <mat### [at] gmailcom> wrote in message
> > news:web.48e3fa9f79b5340cd8a103ef0@news.povray.org...
> >> Now what I really want to do is have "content.inc" and
> >> "othercontent.inc" and
> >> "stillothercontent.inc" then modify the template to contain '#include
> >> Content'
> >> and have the specific include file chosen via the command line
> >> something like
> >> this:  povray -Itemplate.pov Declare=Content="content.inc"  Alas, the
> >> command-line version of Declare appears to be limited to floats.
> >
> > Three approaches immediately spring to mind.
>
> It is a lot easier than that:
>
> Use the Include_Header / +HI command-line option. Documentation at
> http://www.povray.org/documentation/view/3.6.1/220/ .
>
>  Thorsten

That's great for the *first* header, but I need it to be at the *end* of the
file, since the content file will have macros and textures and other stuff
that's referred to in the template or included by the template's include files.


Post a reply to this message

From: Chris B
Subject: Re: How to pass a string from the command line - help?
Date: 2 Oct 2008 08:24:14
Message: <48e4bd6e$1@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message 
news:48e4a6d7$1@news.povray.org...
> Chris B wrote:
>>
>> "Mathuin" <mat### [at] gmailcom> wrote in message 
>> news:web.48e3fa9f79b5340cd8a103ef0@news.povray.org...
>>> Now what I really want to do is have "content.inc" and 
>>> "othercontent.inc" and
>>> "stillothercontent.inc" then modify the template to contain '#include 
>>> Content'
>>> and have the specific include file chosen via the command line something 
>>> like
>>> this:  povray -Itemplate.pov Declare=Content="content.inc"  Alas, the
>>> command-line version of Declare appears to be limited to floats.
>>
>> Three approaches immediately spring to mind.
>
> It is a lot easier than that:
>
> Use the Include_Header / +HI command-line option. Documentation at 
> http://www.povray.org/documentation/view/3.6.1/220/ .
>
> Thorsten

Ah yes. I must have been asleep in the POV101 class when that was covered 
:-)

Chris B.


Post a reply to this message

From: Chris B
Subject: Re: How to pass a string from the command line - help?
Date: 2 Oct 2008 08:30:07
Message: <48e4becf$1@news.povray.org>
"Mathuin" <mat### [at] gmailcom> wrote in message 
news:web.48e4bc28b41ac224d8a103ef0@news.povray.org...
>
> That's great for the *first* header, but I need it to be at the *end* of 
> the
> file, since the content file will have macros and textures and other stuff
> that's referred to in the template or included by the template's include 
> files.

One way round that is to wrap the contents of the include file in a macro 
definition then include the file at the start and run the macro wherever in 
your SDL you need it (there may be an even simpler way that I've missed 
:o)).

Regards,
Chris B.


Post a reply to this message

From: Mathuin
Subject: Re: How to pass a string from the command line - help?
Date: 2 Oct 2008 09:05:00
Message: <web.48e4c0cab41ac224d8a103ef0@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> Chris B wrote:
> >
> > "Mathuin" <mat### [at] gmailcom> wrote in message
> > news:web.48e3fa9f79b5340cd8a103ef0@news.povray.org...
> >> Now what I really want to do is have "content.inc" and
> >> "othercontent.inc" and
> >> "stillothercontent.inc" then modify the template to contain '#include
> >> Content'
> >> and have the specific include file chosen via the command line
> >> something like
> >> this:  povray -Itemplate.pov Declare=Content="content.inc"  Alas, the
> >> command-line version of Declare appears to be limited to floats.
> >
> > Three approaches immediately spring to mind.
>
> It is a lot easier than that:
>
> Use the Include_Header / +HI command-line option. Documentation at
> http://www.povray.org/documentation/view/3.6.1/220/ .
>
>  Thorsten

Wait, I think I get it.  Are you suggesting this?

povray +Icontent.pov +HItemplate.inc

instead of what I was saying before?  If I want to run another content file and
I have another template that has say a different light source or camera
location, I'd run something like this:

povray +Iothercontent.pov +HIdifferenttemplate.inc

Interesting.  I'll have to be very careful with the template files, specifying
exactly what they have to have, but I think it might work.


Post a reply to this message

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