 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I am working on some macros to generate .inc files based on some long-running
calculations to avoid having to do those calculations on every render. I'd like
to make them generic enough so I can write to the console as well as to a file,
but it doesn't look like there are built-in file handles that can be used with
#write for the debug or any other output streams.
Am I missing something, or do I need to do some kludgy things to allow for both
options?
-- Chris R
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Chris R" <car### [at] comcast net> wrote:
> I am working on some macros to generate .inc files based on some long-running
> calculations to avoid having to do those calculations on every render. I'd like
> to make them generic enough so I can write to the console as well as to a file,
> but it doesn't look like there are built-in file handles that can be used with
> #write for the debug or any other output streams.
>
> Am I missing something, or do I need to do some kludgy things to allow for both
> options?
>
> -- Chris R
All I'm aware of are
#debug
#warning
#error
-BW
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
> "Chris R" <car### [at] comcast net> wrote:
> > I am working on some macros to generate .inc files based on some long-running
> > calculations to avoid having to do those calculations on every render. I'd like
> > to make them generic enough so I can write to the console as well as to a file,
> > but it doesn't look like there are built-in file handles that can be used with
> > #write for the debug or any other output streams.
> >
> > Am I missing something, or do I need to do some kludgy things to allow for both
> > options?
> >
> > -- Chris R
>
> All I'm aware of are
> #debug
> #warning
> #error
>
>
> -BW
Thanks. I'll work around it.
Follow-up question: it appears you can't pass file handles as parameters to
macros. No tricks for that either?
-- Chris R
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
hi,
"Chris R" <car### [at] comcast net> wrote:
> "Bald Eagle" <cre### [at] netscape net> wrote:
> > ...
> > -BW
> Thanks. I'll work around it.
>
> Follow-up question: it appears you can't pass file handles as parameters to
> macros. No tricks for that either?
no, alas. (there was a fairly recent thread on this issue, sorry, no ref)
regards, jr.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 19/06/2025 15:51, jr wrote:
> hi,
>
> "Chris R" <car### [at] comcast net> wrote:
>> "Bald Eagle" <cre### [at] netscape net> wrote:
>>> ...
>>> -BW
>> Thanks. I'll work around it.
>>
>> Follow-up question: it appears you can't pass file handles as parameters to
>> macros. No tricks for that either?
>
> no, alas. (there was a fairly recent thread on this issue, sorry, no ref)
>
>
> regards, jr.
>
I was the one who asked about this problem.
I've tried several things (even with Parse_String()) without success :(
--
kurtz le pirate
compagnie de la banquise
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 2025-06-19 09:39 (-4), Chris R wrote:
>
> Follow-up question: it appears you can't pass file handles as parameters to
> macros. No tricks for that either?
Here's my workaround:
---%<-----%<-----%<---[BEGIN CODE]---%<-----%<-----%<---
#macro Write_something (Filename, N)
#fopen F Filename append
#write (F, N)
#fclose F
#end
#declare FILE1 = "test.txt"
#fopen F FILE1 write #fclose F //zero the output file
Write_something (FILE1, "Hello,\n")
Write_something (FILE1, "world.\n")
--->%----->%----->%----[END CODE]---->%----->%----->%---
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 6/19/25 08:46, Chris R wrote:
> Am I missing something, or do I need to do some kludgy things to allow for both
> options?
For the record, and though it is in the "kludgy things" category, one
can use some variation of the following example code on Unix/Linux:
//---
// this.pov
// Unix/Linux ways to write text to stdout stderr more directly.
// Method uses post_scene_command, so set [Shellout Security] to
// allowed in your povray.conf file.
#fopen FH_stdout "My_stdout_file" write
#fopen FH_stderr "My_stderr_file" write
#fclose FH_stdout
#fclose FH_stderr
#if (1) // Set to 0 to empty the My_std* files
#fopen FH_stdout "My_stdout_file" write
#fopen FH_stderr "My_stderr_file" write
#else
#fopen FH_stdout "/dev/null" append
#fopen FH_stderr "/dev/null" append
#end
// Normal scene SDL work starts here
#version 3.8;
global_settings { assumed_gamma 1 }
background {rgb <1,1,0>}
// ...
#write(FH_stdout,"===> Hello stdout\n")
#write(FH_stderr,"===> Hello stderr\n")
// ...
// Normal scene SDL work ends here
#fclose FH_stdout
#fclose FH_stderr
// With yuqk and official povray the supporting ini command lines
// can be:
//
// post_scene_command="cat My_stdout_file >/dev/stdout;cat
My_stderr_file >/dev/stderr"
//
// Run with:
// yuqk this.pov include_ini=this.ini
// or
// povray this.pov include_ini=this.ini
//
// With yuqk you can do it all on the command line too with the
// same ini style quoting here and usual Unix/Linux quoting otherwise.
// (Official POV-Ray cli quoting works too, but its form is strange)
//
// Run with, say:
// yuqk this.pov post_scene_command="cat My_stderr_file" >/dev/stderr
//
// To write meta data at the end of .ppm image output, for example -
// as the .ppm format allows appending text, you can then do
// something like:
//
// yuqk this.pov +fp post_scene_command="cat My_stderr_file" >>hmm.ppm
//
// given you've used FH_stderr for your image's user, meta data.
//
//---
Aside: This method a reason the yuqk fork has kept the +-hi /
include_header= option and is considering an include_trailer= option.
Also under consideration, are new user_ 'file handle' cli / ini options
which would set up some number of explicit user file handles for use
with #write(). We'll see.
Bill P.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 6/19/25 16:15, William F Pokorny wrote:
> // yuqk this.pov +fp post_scene_command="cat My_stderr_file" >>hmm.ppm
Though it worked in my hacking environment, the referenced line above -
for the posted example code - should read:
// yuqk this.pov +fp post_scene_command="cat My_stderr_file" >>this.ppm
Bill P.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 19/06/2025 18:24, Cousin Ricky wrote:
> On 2025-06-19 09:39 (-4), Chris R wrote:
>>
>> Follow-up question: it appears you can't pass file handles as parameters to
>> macros. No tricks for that either?
>
> Here's my workaround:
>
> ---%<-----%<-----%<---[BEGIN CODE]---%<-----%<-----%<---
> #macro Write_something (Filename, N)
> #fopen F Filename append
> #write (F, N)
> #fclose F
> #end
>
> #declare FILE1 = "test.txt"
> #fopen F FILE1 write #fclose F //zero the output file
> Write_something (FILE1, "Hello,\n")
> Write_something (FILE1, "world.\n")
> --->%----->%----->%----[END CODE]---->%----->%----->%---
>
Ingenious approach. I had started with the logic of opening all my files
and choosing to write in this one or that one. I closed all my files at
the end.
With your clever solution, when you write to a file, you open and close
it each time.
Below is a stupid code that illustrates your concept and works really
well with multiple files.
// ---------------------------------------------------------------------
#declare odd = function(x) {select(mod(x, 2), 1, 0, 1)} // no include
// ---------------------------------------------------------------------
#macro Write_something (Filename, N)
#fopen F Filename append
#write (F, concat(str(N,0,0),"\n"))
#fclose F
#end
// ---------------------------------------------------------------------
#macro Create_file(Filename)
#fopen F Filename write
#fclose F
#end
// ---------------------------------------------------------------------
#declare N = 5;
#declare Files = array[N]
#declare i = 0;
#while ( i < N )
#declare Files[i] = concat("file",str(i,0,0),".txt");
Create_file(Files[i])
#declare i = i +1;
#end
#declare i = 0;
#while ( i < 25 )
Write_something(Files[mod(i,N)],i)
#declare i = i + 1;
#end
#error "Nothing to draw"
// ---------------------------------------------------------------------
Thanks for your tip ;)
--
kurtz le pirate
compagnie de la banquise
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |