From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost2.xs4all.net!news.kpn.nl!not-for-mail From: "ldries46" Newsgroups: comp.lang.ada References: <5bf3c62a$0$14970$e4fe514c@news.kpn.nl> In-Reply-To: <5bf3c62a$0$14970$e4fe514c@news.kpn.nl> Subject: Re: Problem with Saving and printing a Gtk Textbuffer Date: Tue, 20 Nov 2018 14:12:18 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 Message-ID: <5bf40833$0$14959$e4fe514c@news.kpn.nl> NNTP-Posting-Host: a579ebc6.news.kpn.nl X-Trace: G=V58XBiOH,C=U2FsdGVkX1/TXebbwIr5hTrleO0wkV9VsG4GeQXMwT7bIffDhzz8950ZBXgKeF+Gya2PHlH85gvYMvD4SX1TPkAC55hM+5gpQW0R0mdZwcE= X-Complaints-To: abuse@kpn.nl Xref: reader01.eternal-september.org comp.lang.ada:54850 Date: 2018-11-20T14:12:18+01:00 List-Id: In the mean time I made this loop working by changing the value of len. len was 50 lines but the loop ony works with 48 lines so I changed nr < len in nr < len - 1. I don't understand why this is so if anyone can tell me why or can give me a better solution i would be happy. "ldries46" schreef in bericht news:5bf3c62a$0$14970$e4fe514c@news.kpn.nl... I have a Gtk Textbuffer with some text in it. I want to save or print the contents of the buffer therefore I use in both cases about the same construction with transporting to a string in a put Line for saving and , as shown in the example code, to a drawbuffer used for printing. Get_Start_Iter(Draw_Buffer, start_it); Get_End_Iter(Draw_Buffer, end_it); Draw_Buffer.Delete(start_it, end_it); len := Main_Window.Output_Buffer.Get_Line_Count; nr := 1; while nr < len loop Get_Iter_At_Line(Main_Window.Output_Buffer, start, nr); Get_Iter_At_Line_Offset(Main_Window.Output_Buffer, stop, nr, 500); str := To_Unbounded_String(Main_Window.Output_Buffer.Get_Text(start, stop)); Num_Line := Get_Back(str); Draw_Buffer.Insert_At_Cursor(To_String(Num_Line.str & CRLF)); nr := nr + 1; end loop; With saving after the loop is an Close statement voor the file,with printing the the printing is initiated there. The problem is that somewhere within the loop the program crashes and I cannot find where. I used exceptitons to run the program to the end and found with saving that the file exists but is not closed. Closing the program also closes the file and I can see that the contents of the file is correct. Before stopping the program the operating system tells me that another program is using the file when trying to open it with wordpad. The pproblem with printing is simular. Who can help me? Bertus Dries