Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetTextBuf changes my Form's caption .. ???

Status
Not open for further replies.

Tilen

Programmer
Apr 2, 2005
75
SI
Hi all

anybody knows why when I use SetTextBuf function it changes my Form's caption?

This is what I use:

const
BufferSize = 8*1024;
var
ABuffer:TPointer;
...

AssignFile(File,ExportFileName.Text);
GetMem(ABuffer, BufferSize);
SetTextBuf(ABuffer);
Reset(File);

...

CloseFile(File);
FreeMem(ABuffer, BufferSize);

...


It changes my Form's caption into some strange characters, like : § Í:? each time something else.

Am I doing something wrong? I'm changing buffer size for readln speed-up.

Thanx
 
Have you read the help section on GetMem, and Settextbuffer
It certainly looks as if you are overwriting program memory.
The example does not use dynamically allocted memory in the way you do here.


Steve: Delphi a feersum engin indeed.
 
Are you mixing Turbo Pascal with Delphi?

As long as it is for normal programming routines, it is OK. But Delphi objects have their own functions/procedures

Steven
 
SetTextBuf() usually wants a continguous known set of bytes, if you reference the example. I don't know what you are getting necessarily by TPointer. I'd consider trying either a static array of the size you want or a typed pointer describing the array you want. It does indeed seem like you are overwriting memory.
 
I got this example from googling, so I just did a plain copy&paste. It could be a turboPascal code... Silly me :)

Thanx for comments, I'll try different approach. I thought it's a small mistake I made, but obviously it's completely wrong way to go.

Thanx

 
this is correct usage:

var BufferSize : array [1..8192] of Char;

...

assignfile(File,ExportFileName.Text);
System.SetTextBuf(File,Buffersize);
reset(File);

...

If I don't use System.SetTextBuf .. it takes SetTexBuf from TControl.

Now it doesn't change my Form's caption.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top