program OOP_design; //example with objects and exception handling //open a file, add a line, save to another file, show the result on the screen //solution to pas_oodesign5.txt //shows with .loadFromFile polymorphie //add a second parameter file 'filename' at last in getFiletoStr(); loc's=57 function getFiletoStr(strObj: TStringList): TStringList; begin //strObj.loadfromfile() result:= strObj; with result do begin clear; loadFromFile('firstdemo.txt'); end end; procedure showFileonMemo(myfile: string); var Mst: TMemoryStream; begin Mst:= TMemoryStream.Create; try Mst.LoadFromFile(myfile); Mst.Seek(0,0); Memo2.Lines.LoadFromStream(Mst); finally Mst.Free; end; end; //main topic begin //constructor with getFileToStr(TStringList.create) do begin //myFileStr:= getFileToStr(myFilestr); add('new line in list'); SaveToFile('firstdemo2.txt') showFileonMemo('firstdemo2.txt'); //destructor Free; end end. ____ ___ _ ____ _ _ _ | _ \ | _| | | | _ \ | | | | | | | | . | | |_ | | | |_| | | |_| | | | | | | | | _| | | | __/ | _ | | | | |_. | | |_ | |__ | | | | | | | | |____/ |___| |____| |_| |_| |_| |_|