그래서 사용자가 특정 이름의 텍스트 파일을 검색 할 수 있도록이 코드를 작성한 다음 텍스트 파일의 이름을 입력하고 실제로 해당 행에 쓰여진 내용을 편집합니다. 즉 라이온스라는 텍스트 파일을 검색 한 다음 이름이 Michael과 같은 줄을 편집합니다. \ 유일한 문제는 편집하는 동안 이름이 이전에 있던 내용을 덮어 쓰는 것입니다. 제 말은 원래 이름 인 Alexander가 그 이름을 mike로 변경하기 위해 해당 레코드를 편집하면 텍스트 파일에 남아있는 문자가 그대로 유지되어 텍스트 파일의 이름이 Mikeander라는 것입니다. 나머지 편지는 보관했습니다. 이것은 레코드의 모든 항목에 대해 발생합니다. 검색 및 파일 검색
type
TCustomer = Record
FirstName : String[15];
LastName : String[15];
EventDate : String[15];
SeatNumber : String[100];
PhoneNumber : String [100];
Adress : String[100]
end;
var
Form4 : TForm4;
FirstName : string;
LastName : String;
EventDate : String;
SeatNumber : String;
PhoneNumber : String;
Adress : String;
begin
usersFilename := Inputbox('Which event needs its details edited?', '', '');
oldname := inputbox('Old Name','Input old name','');
newname := inputbox('New Name','Input new name','');
AssignFile(myFile, usersFilename);
Reset(myFile);
//Find the right record position by searching the file for the namne
count := 0;
while not Eof(myFile) do
begin
Read(myFile, Customer);
if Customer.FirstName = oldname then
recordNumber := count;
count := count+1;
end;
//Seek finds that record in the file and points at it, the read will read the current record
Seek(myFile, recordNumber) ;
Read(myFile,Customer) ;
//Set the new name for that record into our customer record
Customer.FirstName := newName;
Customer.LastName := Inputbox('Last Name', '', '');
Customer.EventDate := Inputbox('Event Date', '', '');
Customer.SeatNumber := Inputbox('Seat Number', '', '');
Customer.PhoneNumber := Inputbox('Phone Number', '', '');
Customer.Adress := Inputbox('Adress', '', '');
//read moves to the next record, so we have to go back again to the original record, then write
Seek(myFile, recordNumber);
//Write the current record which just has the name updated
Write(myFile, Customer);
showmessage('Successfully updated name');
CloseFile(myFile);
end;
어떻게 완전히 원래의 단어를 제거해야합니다 말해 수 있다면
, 대신 그냥 내가 그것을 대단히 감사하겠습니다 새로운 단어와 함께 그것을 매쉬업. 감사합니다
"텍스트 파일의 이름이 Mikeander입니다."다음 번에 프로그램이 표시하는 것에서부터, 또는 파일을 통해 볼 수있는 내용을 어떻게 알 수 있습니까? 16 진수 편집기/뷰어? – MartynA
길이 표시기 때문에이 글자는 중요하지 않습니다. 그러나 당신이 주장한다면, 당신은'FillChar'로 원하는 필드를 "zeroize"할 수 있습니다. –