bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Wed Nov 18, 2009 2:59 pm Post subject: Please help with VDS6 file I/O |
|
|
hi,
i'm trying to get by with binary file-copy.
i found an example for VDS5 and because "@read()" and "write" should be the replacement for "@binfile()" and "binfile", i tried the same way.
But it seems, that with VDS6 you can only write 1 byte at a time (and this first has to be rid of the trailing fieldsep). that differs from what i interpret the helpfile.
"@read()" returns binary data separated by fieldseps while "write" cannot handle these characters and stops with "non numeric" error.
I don't know if it's a bug in the write command or if i'm wrong. Could you help me please?
Here ist a VDS5 code-snippet from this post (see SnarlingSheeps answer):
http://forum.vdsworld.com/viewtopic.php?t=2268&highlight=hex+binary
| Code: |
BINFILE OPEN,1,%%InFile,READ
BINFILE OPEN,2,%%OutFile,CREATE
REPEAT
BINFILE SEEK,1,%%Pos
BINFILE SEEK,2,%%Pos
%%Read = @BINFILE(READ,1,BINARY,%%Bytes)
BINFILE WRITE,2,BINARY,%%Read
%%Pos = @FADD(%%Pos,%%Bytes)
UNTIL @BINFILE(EOF,1)
BINFILE CLOSE,1
BINFILE CLOSE,2
|
And here is what i'm trying to do with VDS6:
| Code: |
%I = @new(file,<InputFile>,read)
%O = @new(file,<OutputFile>,create)
%z = 0
repeat
seekfile %I,%z
%x = @read(%I,32,binary)
if %x
write %O,%x,binary
end
%z = @succ(%z)
until @filepos(%I,eof)
closefile %I
closefile %O
|
Hmmm, strange - If i omit both "binary", it works, but for a 200kB input-file i get a 1599kB output.
It's a pity that this behaviour doesn't apply to my money
Thanks in advance. |
|