|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Consider then following code;
#fopen FN FileName read
#ifdef (FN)
#while (defined(FN))
#read ( FN , Vector)
action( Vector )
#end
#end
After processing Filename001 - FileName100, the next file doesn't exist
(FileName101). Afaik #ifdef (FN) should catch that and not allow the #while
loop to continue.
Or am I missing something?
--
Ger
Using Pov 3.7 on Linux
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ger wrote:
> #fopen FN FileName read
> #ifdef (FN)
> #while (defined(FN))
> #read ( FN , Vector)
> action( Vector )
> #end
> #end
the documentation of #fopen states that IDENTIFIER should be
an undefined identifier. So it might be that the #ifdef test
only works if FN was not alreaday defined prior to #fopen.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Christian Froeschlin wrote:
> Ger wrote:
>
>> #fopen FN FileName read
>> #ifdef (FN)
>> #while (defined(FN))
>> #read ( FN , Vector)
>> action( Vector )
>> #end
>> #end
>
> the documentation of #fopen states that IDENTIFIER should be
> an undefined identifier. So it might be that the #ifdef test
> only works if FN was not alreaday defined prior to #fopen.
From the manual
<
You may use #ifdef FILE_HANDLE_IDENTIFIER to see if a file is open.
>
--
Ger
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 17-11-2012 20:22, Ger wrote:
> Consider then following code;
>
> #fopen FN FileName read
> #ifdef (FN)
> #while (defined(FN))
> #read ( FN , Vector)
> action( Vector )
> #end
> #end
>
> After processing Filename001 - FileName100, the next file doesn't exist
> (FileName101). Afaik #ifdef (FN) should catch that and not allow the #while
> loop to continue.
>
> Or am I missing something?
>
I wonder: shouldn't #fopen not give a parse error message when trying to
open a non-existing file? Before even #ifdef()?
I remember having misquoted a filename and having the parser abort.
[quote]You may use #ifdef FILE_HANDLE_IDENTIFIER to see if a file is
open[unquote] only tests if the file is /open/ not if it /exists/. That
might be a subtle difference...
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 17.11.2012 20:22, schrieb Ger:
> Consider then following code;
>
> #fopen FN FileName read
> #ifdef (FN)
> #while (defined(FN))
> #read ( FN , Vector)
> action( Vector )
> #end
> #end
>
> After processing Filename001 - FileName100, the next file doesn't exist
> (FileName101). Afaik #ifdef (FN) should catch that and not allow the #while
> loop to continue.
Well, if FN is undefined, the #while loop itself should refuse to run
even a single time, so the #ifdef is redundant.
But if the file doesn't exist, #fopen doesn't fail with an undefined FN,
but rather with an error message.
You might want to use the following code:
#if (file_exists(FileName))
#fopen ...
#while ...
...
#end
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |