Board index » delphi » blockwrite wrong file size

blockwrite wrong file size

hi out there,

this problem is driving me nuts under d1.02: i need
to translate a memo of an old dos dbase IV file (ASCII)
to the standard windows ANSI character set. i took the
memofield and saved it into a file, whose filename is
indicated by imp_wiz_main.memofilename. then i load
it into a dynamically created buffer of 32k. the
files to be translated are 6kb max, but mostly about some
hundred bytes. the winprocs.oemtoansi works very fine.

BUT: the problem is that after the marked line,
the (saved!) file becomes much bigger; e.g.
numread is 57 bytes and filesize is afterwards
6192 bytes. i even tried to put my type, var
and memory allocation outside of my timp_wiz_main
form declaration, but it does NOT work in any case.
what is the thing that's missing here?

any help appreciated

stefan gebers
email: stefan.geb...@stud.uni-hannover.de

function TImp_wiz_main.oem(const zeile : string):string;
  begin
    result:=zeile+#0;
    winprocs.oemtoansi(@result[1],@result[1]);
    dec(result[0]);
  end;

Procedure TImp_wiz_main.alloem;
type tmyarray= array[0..32000] of char;
var i, numread:word;
    fx:file;
    myarray:^tmyarray;
begin
 with importedrecord^ do
  begin
    autoren:=oem(Autoren);
     .
     .
     .
    titel:=oem(Titel);
  end; {with do}

 new(myarray);
 assignfile(fx, imp_wiz_main.memofilename);
 reset(fx,1);
 blockread(fx, myarray^, 32000, numread);
 myarray^[numread]:=#0;
 winprocs.oemtoansi(@myarray^[0],@myarray^[0]);
 closefile(Fx);
 reset(fx);
 blockwrite(fx, myarray^, numread);
 closefile(Fx);                             {<--- here!}
 dispose(myarray);
end;

--

 

Re:blockwrite wrong file size


Quote
Stefan Gebers wrote:

> hi out there,

> this problem is driving me nuts under d1.02: i need
> to translate a memo of an old dos dbase IV file (ASCII)
> to the standard windows ANSI character set. i took the
> memofield and saved it into a file, whose filename is
> indicated by imp_wiz_main.memofilename. then i load
> it into a dynamically created buffer of 32k. the
> files to be translated are 6kb max, but mostly about some
> hundred bytes. the winprocs.oemtoansi works very fine.

> BUT: the problem is that after the marked line,
> the (saved!) file becomes much bigger; e.g.
> numread is 57 bytes and filesize is afterwards
> 6192 bytes. i even tried to put my type, var
> and memory allocation outside of my timp_wiz_main
> form declaration, but it does NOT work in any case.
> what is the thing that's missing here?

> any help appreciated

> stefan gebers
> email: stefan.geb...@stud.uni-hannover.de

> function TImp_wiz_main.oem(const zeile : string):string;
>   begin
>     result:=zeile+#0;
>     winprocs.oemtoansi(@result[1],@result[1]);
>     dec(result[0]);
>   end;

> Procedure TImp_wiz_main.alloem;
> type tmyarray= array[0..32000] of char;
> var i, numread:word;
>     fx:file;
>     myarray:^tmyarray;
> begin
>  with importedrecord^ do
>   begin
>     autoren:=oem(Autoren);
>      .
>      .
>      .
>     titel:=oem(Titel);
>   end; {with do}

>  new(myarray);
>  assignfile(fx, imp_wiz_main.memofilename);
>  reset(fx,1);
>  blockread(fx, myarray^, 32000, numread);
>  myarray^[numread]:=#0;
>  winprocs.oemtoansi(@myarray^[0],@myarray^[0]);
>  closefile(Fx);
>  reset(fx);               <----- should rewrite
>  blockwrite(fx, myarray^, numread);
>  closefile(Fx);                             {<--- here!}
>  dispose(myarray);
> end;

> --

Re:blockwrite wrong file size


Quote
Stefan Gebers wrote:
> hi out there,
> this problem is driving me nuts under d1.02: i need
> to translate a memo of an old dos dbase IV file (ASCII)
> to the standard windows ANSI character set. i took the
> memofield and saved it into a file, whose filename is
> indicated by imp_wiz_main.memofilename. then i load
> it into a dynamically created buffer of 32k. the
> files to be translated are 6kb max, but mostly about some
> hundred bytes. the winprocs.oemtoansi works very fine.
> BUT: the problem is that after the marked line,
> the (saved!) file becomes much bigger; e.g.
> numread is 57 bytes and filesize is afterwards
> 6192 bytes. i even tried to put my type, var
> and memory allocation outside of my timp_wiz_main
> form declaration, but it does NOT work in any case.
> what is the thing that's missing here?
> any help appreciated

> function TImp_wiz_main.oem(const zeile : string):string;
> Procedure TImp_wiz_main.alloem;

>  new(myarray);
>  assignfile(fx, imp_wiz_main.memofilename);
>  reset(fx,1);
>  blockread(fx, myarray^, 32000, numread);
>  myarray^[numread]:=#0;
>  winprocs.oemtoansi(@myarray^[0],@myarray^[0]);
>  closefile(Fx);
>  reset(fx);

> reset(FX,1)  or rewrite(FX,1)  ????
>  blockwrite(fx, myarray^, numread);
>  closefile(Fx);                             {<--- here!}
>  dispose(myarray);
> end;

> --

Other Threads