Board index » delphi » File Modifications

File Modifications

Is it possible (Haven't tried yet) to set a record from one value to
another
while the file is currently open ? I have an idea of something like
this:

Program Test;

Uses DOS, CRT;

TYPE TestNDX = record
PathName = STRING[30];
Color    = Byte;
Name     = STRING[32];
Address  = STRING[32];
END;

Var
TIndex : TestNDX;

Begin

Assign(F,'TEST.DAT');
Reset(F,1);
BlockRead(F, TIndex, SizeOf(TIndex), ReadResult);

Writeln('Currently Value PathName is set to ', TIndex.PathName);
Writeln('Currently Value TextColor is set to ', TIndex.Color);

TIndex.Color := 4;

BlockWrite(F,TIndex, SizeOf(TIndex), ReadResult);

Close(F);

end.

So is it possible to Modify ONLY the TIndex.Color in the file
WITHOUT destroying other data for example Name, Address and PathName
for example ??

Will this do the trick ? Or do I need to add or modify something ?

I am using Turbo Pascal 7 for DOS

Thanks in advance for your replies !!

* Armando Silva *

 

Re:File Modifications


Quote
Armando Silva wrote:
> Program Test;

> Uses DOS, CRT;

> TYPE TestNDX = record
> PathName = STRING[30];
> Color    = Byte;
> Name     = STRING[32];
> Address  = STRING[32];
> END;

> Var
> TIndex : TestNDX;

> Begin

> Assign(F,'TEST.DAT');
> Reset(F,1);
> BlockRead(F, TIndex, SizeOf(TIndex), ReadResult);

> Writeln('Currently Value PathName is set to ', TIndex.PathName);
> Writeln('Currently Value TextColor is set to ', TIndex.Color);

> TIndex.Color := 4;

> BlockWrite(F,TIndex, SizeOf(TIndex), ReadResult);

> Close(F);

> end.

> So is it possible to Modify ONLY the TIndex.Color in the file
> WITHOUT destroying other data for example Name, Address and PathName
> for example ??

Sure. Read the record from the file, modify the field that you want
to modify and write back the record. Heed the current position in
the file. (See the online help for the Seek procedure).

Re:File Modifications


Quoting FREDERIC BONROY to ALL concerning File Modifications:

Quote
>Sure. Read the record from the file, modify the field that you want
>to modify and write back the record. Heed the current position in
>the file. (See the online help for the Seek procedure).

>--- Internet Rex 2.26
>* Origin: None (1:396/4000.999)

I got it ! Thanks !

[Armando]

... Quadrotriticale....3.56 billion tribbles can't be wrong!
___ ZapReader v0.60

Other Threads