اساس کار من روی رکوردهاست یک رکورد با پنج فیلد از نوع رشته تعریف کرده ام
وقتی از روش سنتی پاسکال برای کار با فایلها استفاده می کنید، نباید از فیلدهایی با نوع string در رکورد فایل استفاده کنید. چون نوع string در دلفی نوع خاصی هست و با نوع string در پاسکال فرق داره.
برای رفع این مشکل می تونید یکی از راههای زیر رو انتخاب کنید:
1- استفاده از نوع shortstring (همون نوعی که پاسکال هم ازش استفاده می کرد) بجای string برای فیلدها.
2- استفاده از TFileStream بجای روش قدیمی پاسکال.
در ضمن اگر هنگام مشاده خطا یکبار F1 رو میزدید، کارتون راحتتر میشد:
دوستان اگه لطفی کنید و سوال من رو جواب بدید یک دنیا ممنون می شم چون کار فوری و ضروری است و توی هلپ دلفی هم چیزی پیدا نکردم
از راهنمای دلفی:
Certain types are treated specially by the compiler on an internal basis in that they must be correctly finalized to release any resources that they might currently own. Because the compiler cannot determine what type is actually stored in a record's variant section at runtime, it is not possible to guarantee that these special data types are correctly finalized.
program Produce;
type
Data = record
name : string;
end;
var
inFile : file of Data;
begin
end.
String is one of those data types which need finalization, and as such they cannot be stored in a File type.
program Solve;
type
Data = record
name : array [1..25] of Char;
end;
var
inFile : file of Data;
begin
end.
One simple solution, for the case of String, is to redeclare the type as an array of characters. For other cases which require finalization, it becomes increasingly difficult to maintain a binary file structure with standard Pascal features, such as 'file of'. In these situations, it is probably easier to write specialized file I/O routines.
:موفق: