files copying has failed

new BookmarkLockedFalling
daniel
New Member
*

daniel Avatar

Posts: 1Male

Post by daniel on Feb 28, 2014 15:21:11 GMT -5

If you try to copy a file, e.g. an image file, using the following lines (taken from liberty basic examples)



open "mandelbrot.jpg" for input as #original

open "copy.jpg" for output as #copy

print #copy, input$(#original, lof(#original));

close #original

close #copy

end



the copy.jpg file is corrupted
:o


again , if you try the same with a binary way, like



open "mandelbrot.jpg" for input as #original

a$ = input$(#original, lof(#original))

lenght = lof(#original)

close #original

open "copy.jpg" for random as #copy len = lenght

field #copy, lenght as a$

put #copy,1

close #copy



the file copy.jpg is corrupted again
>:D

I examined with attention the original and the corrupted file discovering a(possible) reason for that.

When the file is written, all the bytes 0D (carriage return,chr$(13)) are substituted by two bytes , namely 0D + 0A

(carriage return + line feed). This seems to happen in whatever fashion you open the file for writing.

How can we overcome the problem ????





StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM