Board index » off-topic » Blockwrite equivalent

Blockwrite equivalent


2006-11-01 11:49:53 PM
off-topic12
Hi,
Does anyone know what Blockwrite() is doing? I need to rewrite this
function in C# .NET. Please help.
Thanks!
I
 
 

Re:Blockwrite equivalent

I T schrieb:
Quote
Hi,

Does anyone know what Blockwrite() is doing? I need to rewrite this
function in C# .NET. Please help.

Thanks!
I


I only have the german description from TP Help. I hope its useful anyway.
------------
BlockWrite Prozedur
------------
Schreibt einen oder mehrere Records aus einer
Puffervariablen. f steht für eine untypisierte
Datei, buf für die Puffervariable. Count gibt
die Anzahl der zu schreibenden Records an, der
optionale Parameter result liefert die Anzahl
der tatsächlich geschriebenen Records zurück.
(count <>result -->Diskette voll). Maximal
können mit einem Aufruf von BlockWrite 64
KByte Daten geschrieben werden.
Syntax:
BlockWrite(var f: file; var buf; count: Word
var result: Word])
Siehe auch:
BlockRead
{ Example for BlockRead and BlockWrite }
program CopyFile;
{ Simple copy program w/NO error checking }
var
FromF, ToF: file;
NumRead, NumWritten: Word;
buf: array[1..2048] of Char;
begin
{ Open input file }
Assign(FromF, ParamStr(1));
{ Record size = 1 }
Reset(FromF, 1);
{ Open output file }
Assign(ToF, ParamStr(2));
{ Record size = 1 }
Rewrite(ToF, 1);
WriteLn('Copying ', FileSize(FromF),
' bytes...');
repeat
BlockRead(FromF,buf,
SizeOf(buf),NumRead);
BlockWrite(ToF,buf,NumRead,NumWritten);
until (NumRead = 0) or
(NumWritten <>NumRead);
Close(FromF);
Close(ToF);
end.
 

Re:Blockwrite equivalent

"I T" < XXXX@XXXXX.COM >wrote
Quote
Does anyone know what Blockwrite() is doing?
Remember that programs usually use ReWrite(,)
Reset(,), Seek(), FileSize(), EOF(), and CloseFile()
together with BlockWrite(,,) and BlockRead(,,),
so you might want to consider the equivalent of each
of these other functions, too. --JohnH
 

{smallsort}

Re:Blockwrite equivalent

Hello,
When porting an old TP application to Delphi, I re-wrote all logic by using
TFileStream instead. (I replaced BlockWrite with TFileStream's Write
method.)
So in .NET, I guess you can use FileStream.
Quote
Does anyone know what Blockwrite() is doing? I need to rewrite this
function in C# .NET. Please help.
Best regards,
Erik Lindberg
Localization specialist
www.multilizer.com/
 

Re:Blockwrite equivalent

Erik,
Is it possible to send me your Delphi code? It would be easier to translate
from Delphi to C#.
Thanks!
XXXX@XXXXX.COM
"Erik Lindberg" < XXXX@XXXXX.COM >wrote in message
Quote
Hello,

When porting an old TP application to Delphi, I re-wrote all logic by
using TFileStream instead. (I replaced BlockWrite with TFileStream's Write
method.)
So in .NET, I guess you can use FileStream.

>Does anyone know what Blockwrite() is doing? I need to rewrite this
>function in C# .NET. Please help.

Best regards,
Erik Lindberg
Localization specialist
www.multilizer.com/




 

Re:Blockwrite equivalent

In Turbo Pascal, the blockwrite and blockread functions were use to read and
write blocks of memory; useful for fast reads and writes of large quantities
of data at one time. Not real sure of what the equivilent function in C#
woudl be, but the equivilent C/C++ function would be fread;
"I T" < XXXX@XXXXX.COM >wrote in message
Quote
Hi,

Does anyone know what Blockwrite() is doing? I need to rewrite this
function in C# .NET. Please help.

Thanks!
I

 

Re:Blockwrite equivalent

On 2006-11-03, David Pratt < XXXX@XXXXX.COM >wrote:
Quote
In Turbo Pascal, the blockwrite and blockread functions were use to read and
write blocks of memory; useful for fast reads and writes of large quantities
of data at one time. Not real sure of what the equivilent function in C#
woudl be, but the equivilent C/C++ function would be fread;
There also is a gotcha with blockwrite that can be a difference in some
circumstances. This mostly if the code AFTER the blockwrite uses the value
returned in the optional 4th VAR parameter is used that returns the actual
written bytes (e.g. the number of bytes that was written of a block before
the error occured).
Usually this will be rare, but it is wise to check that this isn't done.
 

Re:Blockwrite equivalent

On Wed, 1 Nov 2006 09:49:53 -0600, "I T" < XXXX@XXXXX.COM >wrote:
Quote
Hi,

Does anyone know what Blockwrite() is doing? I need to rewrite this
function in C# .NET. Please help.

Thanks!
I
It's writing a chunk of memory of undefined type to disk.
Be careful of changes in data alignment between C# and TP.