POV-Ray : Newsgroups : povray.general : Can I not pass a file to a macro? Server Time
26 Nov 2024 05:38:48 EST (-0500)
  Can I not pass a file to a macro? (Message 1 to 4 of 4)  
From: Cousin Ricky
Subject: Can I not pass a file to a macro?
Date: 5 Aug 2011 17:15:00
Message: <web.4e3c5c1e1d69a39a85de7b680@news.povray.org>
When I run:
______________________________________

#version 3.7;

global_settings { assumed_gamma 1 }

#macro Write_something (N, FileID)
   #write (FileID, N)
#end

#fopen F "test.txt" write
Write_something ("Hello, world.\n", F)
#fclose F
______________________________________

I get the error:
______________________________________

"C:\Users\Ricky Callwood\Documents\POV-Ray\test\file_param.pov" line 19: Parse
Error: Expected 2 parameters but only 1 found.
______________________________________

I am running POV-Ray version 3.7RC3.

My OS is the infinitely exasperating Windows 7 Ultimate.


Post a reply to this message

From: B  Gimeno
Subject: Re: Can I not pass a file to a macro?
Date: 5 Aug 2011 19:50:00
Message: <web.4e3c80943ab75a423ab9fa310@news.povray.org>
> When I run:
>
> #version 3.7;
>
> global_settings { assumed_gamma 1 }
>
> #macro Write_something (N, FileID)
>    #write (FileID, N)
> #end
>
> #fopen F "test.txt" write
> Write_something ("Hello, world.\n", F)
> #fclose F

I dunno why, but I cant pass either the fileid as parameter

 #version 3.7;
 global_settings { assumed_gamma 1 }
  #macro Write_something (N)
    #write (f,concat(N))
 #end

#fopen f "test.txt" write

 Write_something ("Hello, world.\n")

I hope to serve this at the moment, removing the fileid parameter

B. Gimeno


Post a reply to this message

From: B  Gimeno
Subject: Re: Can I not pass a file to a macro?
Date: 5 Aug 2011 20:05:00
Message: <web.4e3c85083ab75a423ab9fa310@news.povray.org>
A variation in which you can enter the output filename as a paremeter.

 #macro Write_something (file_name,N)
    #fopen F file_name write
    #write (F,N)
    #fclose F
 #end


 Write_something ("test.txt","Hello, world.\n")


By the way, is there a powerful and unavoidable reason to introduce as a
parameter the id_file handler?

Regards
B. Gimeno


Post a reply to this message

From: Cousin Ricky
Subject: Re: Can I not pass a file to a macro?
Date: 5 Aug 2011 20:55:00
Message: <web.4e3c909e3ab75a4285de7b680@news.povray.org>
"B. Gimeno" <nomail@nomail> wrote:
> By the way, is there a powerful and unavoidable reason to introduce as a
> parameter the id_file handler?

Yes.  If the macro is called more than once.

I found a workaround, though.

#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")


Post a reply to this message

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