POV-Ray : Newsgroups : povray.general : Feature Request: Binary #write : Re: Feature Request: Binary #write Server Time
30 Jul 2024 16:21:58 EDT (-0400)
  Re: Feature Request: Binary #write  
From: Tim Attwood
Date: 25 Mar 2009 23:34:54
Message: <49caf7de$1@news.povray.org>
>> It would be easy enough to fit binary file access into the current SDL
>> framework.
>>
>> FOPEN_DIRECTIVE:
>>     #fopen IDENTIFIER "filename" OPEN_TYPE [FILE_MODE]
>> OPEN_TYPE:
>>     read | write | append
>> FILE_MODE
>>     standard | binary
>
> That alone wouldn't quite do the job: How is POV to know whether to write 
> a
> particular value as a byte, 16-bit or 32-bit integer?
>
> So when invoking #write, the parameters would have to be marked 
> accordingly
> anyway; and in that case the FILE_MODE isn't required at all.

Obviously the standard for binary files is 8 bit bytes.

POV supports encoding and decoding byte values with the
chr(N) and asc(S) functions in ASCII mode.

You can already write byte values as #write(handle,chr(N)).

In binary mode undeclared_identifiers and strings in a #read could just be
treated as 1 byte string chars instead of trying to determine the type from 
the
file content, or trying to find enclosing quotes. Float and vector handling
could be left as-is, or produce a warning.

There is no handling for integer types in POV SDL, everything is really a 
float,
or a string. Still, it might be fun to read in some ASCII art text file and 
try to
render something based on it, or other such stuff. In particular it's a 
bummer
having a big CSV file where the strings aren't enclosed in quotes, or some
other "defect". It would be nice to be able to directly use such stuff in 
POV.


Post a reply to this message

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