JohnE
asked on
Records & Longstrings
It is my understanding that items in a record can only hold up to 255 characters. I need to be able to store information in a record style structure, but I need longstring support. Is there are method to achieve this, either using records or some other structure?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have been able to implement this with error free code, but when I run ( a sample program see below), I always get a EAccessViolation error. It seems to be coming from the getks function?
Type
kstring = record
kslen: integer;
ksdata:array[1..1024] of char
end;
procedure putks(instring:string;var outks:kstring);
begin
outks.kslen := length(instring);
move(instring[1],outks.ksd ata,length (instring) );
end;
function getks(inks:kstring):string ;
var
tmpstr:string;
begin
move(inks.ksdata,tmpstr[1] ,inks.ksle n);
SetLength(tmpstr,inks.ksle n);
getks := tmpstr;
end;
Type
Emp_Rec = record
Emp_Id:string[10];
Emp_Name:string[40];
Emp_Notes:kstring;
end;
var
Employee: Emp_Rec;
procedure TForm2.Button1Click(Sender : TObject);
begin
Employee.Emp_Id := Edit1.Text;
Putks(Edit1.Text, Employee.Emp_Notes);
end;
procedure TForm2.Button2Click(Sender : TObject);
begin
Memo1.Text := getks(Employee.Emp_Notes);
end;
Type
kstring = record
kslen: integer;
ksdata:array[1..1024] of char
end;
procedure putks(instring:string;var outks:kstring);
begin
outks.kslen := length(instring);
move(instring[1],outks.ksd
end;
function getks(inks:kstring):string
var
tmpstr:string;
begin
move(inks.ksdata,tmpstr[1]
SetLength(tmpstr,inks.ksle
getks := tmpstr;
end;
Type
Emp_Rec = record
Emp_Id:string[10];
Emp_Name:string[40];
Emp_Notes:kstring;
end;
var
Employee: Emp_Rec;
procedure TForm2.Button1Click(Sender
begin
Employee.Emp_Id := Edit1.Text;
Putks(Edit1.Text, Employee.Emp_Notes);
end;
procedure TForm2.Button2Click(Sender
begin
Memo1.Text := getks(Employee.Emp_Notes);
end;
ASKER