fox
Junior Member
Posts: 66
|
Post by fox on Mar 27, 2020 12:18:26 GMT -5
Hi all. Please, I would like to know the best way to overwrite the screen with a precedent segment (flushed), using a graphicbox. I tried with command "print #handle, "redraw "; idNum", but I was not able to do it. Thanks to all and bye fox
|
|
|
Post by Rod on Mar 27, 2020 14:52:00 GMT -5
Show more code. If you flush a segment to segn then redraw segn works perfectly well. But the devil is in the detail, how are you coding it?
|
|
fox
Junior Member
Posts: 66
|
Post by fox on Mar 27, 2020 16:22:00 GMT -5
Hi Rod. Thanks a lot for your suggestion. Here a little example: nomainwin graphicbox #1.gr, 100, 80, 1300, 700 open "Little Test" for graphics_nsb_fs as #1 print #1,"trapclose [quit]" x = 0 goto [test] wait
[test] for a = 1 to 3 x = x+100 y = 100 print #1.gr, "backcolor blue" print #1.gr, "down; size 1; set ";x;" ";y; print #1.gr, "circlefilled 10" gosub [flash] next a goto [final] wait [flash] print #1.gr, "flush"; segm = 0 print #1.gr, "segment segm" notice "segm = ";segm return wait [final] numbseg = 0 prompt "Write segment's number to redraw";numbseg print #1.gr, "redraw ";numbseg wait [quit] close #1 end
When I try in [final] to redraw a precedent segment the program does not work as I want. Thanks a lot again and bye
|
|
|
Post by Rod on Mar 28, 2020 4:30:43 GMT -5
Alright. First off I would say Segments are one of my pet hates, they are the least attractive thing about Liberty BASIC. Few people understand them properly and few use them. A necessary evil as far as I am concerned. You make the classic mistake of issuing the flush before you get the segment id number. Always get the id before you flush and so increase the id. Secondly you must understand that the segment is in memory it is not the screen you are looking at. So the three circles will persist on screen over time unless you do something about that. You can't cls because that would erase all your segments. You might draw over or you might have an initial base background that you redraw to set things back to base. Then you can redraw the segments you wish..... alycesrestaurant.com/lbpe/SegmentsAndFlushing.htmlalycesrestaurant.com/lbpe/Graphic%20Segments.htmlThe above tutorials will help. However be sure you really need to use segments as a drawing tool. Simply redrawing everything and keeping a single flushed segment is way way easier. nomainwin graphicbox #1.gr, 100, 80, 1300, 700 open "Little Test" for graphics_nsb_fs as #1 print #1,"trapclose [quit]" x = 0
[test] for a = 1 to 3 x = x+100 y = 100 print #1.gr, "backcolor blue" print #1.gr, "down; size 1; set ";x;" ";y; print #1.gr, "circlefilled 10" gosub [flash] next a gosub [final] wait
[flash] print #1.gr, "segment segm" print #1.gr, "flush"; notice "segm = ";segm return
[final] prompt "Write segment's number to redraw";numbseg print #1.gr, "backcolor white ; fill white ; redraw ";numbseg return
[quit] close #1 end
|
|
fox
Junior Member
Posts: 66
|
Post by fox on Mar 28, 2020 5:35:44 GMT -5
Ah, ok. Thanks a lot, Rod. It is the solution I need. And also I learned a lot of things about segments and graphics commands. Very and very interesting also the 2 links you gave me. Thanks a lot again and bye fox
|
|