POV-Ray : Newsgroups : povray.general : Passing file handles to macros Server Time
6 Aug 2024 06:21:55 EDT (-0400)
  Passing file handles to macros (Message 1 to 9 of 9)  
From: John VanSickle
Subject: Passing file handles to macros
Date: 25 May 2002 10:14:07
Message: <3cef9c2f@news.povray.org>
I was having a bit of trouble with a macro, and learned that file handles
cannot be passed to macros.

As things stand, the only work-around is to pass the file name, and have the
macro open the file, or to specify
a global handle for the macro to use.

Were there any problems encountered with allowing handles to be passed to
macros?

Regards,
John


Post a reply to this message

From: Rune
Subject: Re: Passing file handles to macros
Date: 25 May 2002 10:40:36
Message: <3cefa264@news.povray.org>
John VanSickle wrote:
> I was having a bit of trouble with a macro, and
> learned that file handles cannot be passed to macros.
>
> As things stand, the only work-around is to pass the
> file name, and have the macro open the file, or to
> specify a global handle for the macro to use.

I also think you could use the parse_string macro in POV-Ray 3.5 to
parse a string containing the file handle name if I have understood your
problem correctly.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated May 20)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Tom Melly
Subject: Re: Passing file handles to macros
Date: 25 May 2002 15:49:12
Message: <3cefeab8@news.povray.org>
"John VanSickle" <evi### [at] hotmailcom> wrote in message
news:3cef9c2f@news.povray.org...
> I was having a bit of trouble with a macro, and learned that file handles
> cannot be passed to macros.
>

<snip>

Did this in effect mean that you couldn't open a filehandle outside a macro
and then write to the filehandle inside the macro?


Post a reply to this message

From: John VanSickle
Subject: Re: Passing file handles to macros
Date: 26 May 2002 11:22:05
Message: <3cf0fd9d@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3cefeab8@news.povray.org...
> "John VanSickle" <evi### [at] hotmailcom> wrote in message
> news:3cef9c2f@news.povray.org...
> > I was having a bit of trouble with a macro, and learned that file
handles
> > cannot be passed to macros.
>
> <snip>
>
> Did this in effect mean that you couldn't open a filehandle outside a
macro
> and then write to the filehandle inside the macro?

Yes.

Regards,
John


Post a reply to this message

From: Tom Melly
Subject: Re: Passing file handles to macros
Date: 26 May 2002 15:02:45
Message: <3cf13155@news.povray.org>
"John VanSickle" <evi### [at] hotmailcom> wrote in message
news:3cf0fd9d@news.povray.org...
> >
> > Did this in effect mean that you couldn't open a filehandle outside a
> macro
> > and then write to the filehandle inside the macro?
>
> Yes.
>

Just checking... that's a bit of a blow. I mean, not insummontable, but a
pain.


Post a reply to this message

From: Slime
Subject: Re: Passing file handles to macros
Date: 26 May 2002 15:42:38
Message: <3cf13aae$1@news.povray.org>
> > Did this in effect mean that you couldn't open a filehandle outside a
> macro
> > and then write to the filehandle inside the macro?
>
> Yes.


Well... I may be mistaken, but I believe this works:

#macro dostuff()
#write(MYFILE, "hi")
#end

#fopen MYFILE "myfile.txt" write
dostuff()
#fclose MYFILE

You just can't pass the actual file handle to the macro, so you have to be
able to pre-write the macro knowing what the filehandle will be named. A
significant restriction, yes. Not horrible though.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Passing file handles to macros
Date: 26 May 2002 18:00:08
Message: <3cf15ae8$1@news.povray.org>
In article <3cf0fd9d@news.povray.org> , "John VanSickle" 
<evi### [at] hotmailcom> wrote:

>> Did this in effect mean that you couldn't open a filehandle outside a
>> macro and then write to the filehandle inside the macro?
>
> Yes.

No!

You just cannot make any copies of file handles and thus you can't pass them
as parameters either.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: John VanSickle
Subject: Re: Passing file handles to macros
Date: 27 May 2002 10:28:30
Message: <3cf2428e@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:3cf15ae8$1@news.povray.org...
> In article <3cf0fd9d@news.povray.org> , "John VanSickle"
> <evi### [at] hotmailcom> wrote:
>
> >> Did this in effect mean that you couldn't open a filehandle outside a
> >> macro and then write to the filehandle inside the macro?
> >
> > Yes.
>
> No!
>
> You just cannot make any copies of file handles and thus you can't pass
them
> as parameters either.

I know that (it's in the docs).

Regards,
John


Post a reply to this message

From: John VanSickle
Subject: Re: Passing file handles to macros
Date: 27 May 2002 10:29:49
Message: <3cf242dd@news.povray.org>
"Slime" <slm### [at] slimelandcom> wrote in message
news:3cf13aae$1@news.povray.org...
> > > Did this in effect mean that you couldn't open a filehandle outside a
> > macro
> > > and then write to the filehandle inside the macro?
> >
> > Yes.
>
>
> Well... I may be mistaken, but I believe this works:
>
> #macro dostuff()
> #write(MYFILE, "hi")
> #end
>
> #fopen MYFILE "myfile.txt" write
> dostuff()
> #fclose MYFILE
>
> You just can't pass the actual file handle to the macro, so you have to be
> able to pre-write the macro knowing what the filehandle will be named. A
> significant restriction, yes. Not horrible though.

Yes, unless there is a security problem with allowing handles to be passed
as macro parameters, there is no reason to prohibit it.

Regards,
John


Post a reply to this message

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