|
Post by stan58 on Nov 29, 2018 16:14:15 GMT -5
I have a text editor that I am adding new lines to during the programme . Is there anyway to automatically scroll to the bottom most entry (the newest) whenever a new line is added. I am using a string to add a new text line to and then print the string into the text editor
|
|
|
Post by tsh73 on Nov 30, 2018 7:35:34 GMT -5
Check this.
nomainwin
WindowWidth = 392 WindowHeight = 360
texteditor #main.textedit1, 26, 16, 208, 255 button #main.button2, "add 20 lines#1", [button1Click], UL, 254, 16, 106, 25 button #main.button3, "add 20 lines#2", [button2Click], UL, 254, 66, 106, 25 button #main.button4, "add 20 lines#3", [button3Click], UL, 254, 116, 106, 25 open "untitled" for window as #main print #main, "font ms_sans_serif 0 16"
[main.inputLoop] 'wait here for input event wait
[button1Click] 'Perform action for the button named 'button1' #main.textedit1 "!cls" 'clear first
txt$="" for i = 1 to 20 txt$=txt$+"Line ";i;chr$(13);chr$(10) next #main.textedit1 "!cls" #main.textedit1, txt$ 'printing big string at once: stays on last line wait
[button2Click] 'Perform action for the button named 'button2' #main.textedit1 "!cls" 'clear first
txt$="" for i = 1 to 20 txt$=txt$+"Line ";i;chr$(13);chr$(10) 'note just chr$(13) not enough next #main.textedit1 "!contents txt$" 'adding big string at once: stays on first line wait
[button3Click] 'Perform action for the button named 'button3' #main.textedit1 "!cls" 'clear first
for i = 1 to 20 #main.textedit1, "Line ";i 'adding one by one: stays on last line next wait
|
|
|
Post by stan58 on Nov 30, 2018 10:28:13 GMT -5
Thank you Ran your code ,I get it now. Thanks
|
|
|
Post by metro on Nov 30, 2018 18:28:17 GMT -5
a wise man once said "boleye chem odin sposob kozhi koshki" ......(more than one way to skin a cat)
if you are dropping in a lot of info from a big file........ (print #handle, "!contents #handle" see help
global NumLines 'ADDED
nomainwin
WindowWidth = 392 WindowHeight = 360
texteditor #main.textedit1, 26, 16, 208, 255 button #main.button2, "add 20 lines#1", [button1Click], UL, 254, 16, 106, 25 button #main.button3, "add 20 lines#2", [button2Click], UL, 254, 66, 106, 25 button #main.button4, "add 20 lines#3", [button3Click], UL, 254, 116, 106, 25 button #main.buttonBTM, "Goto Top", [button4Click], UL, 254, 166, 106, 25 button #main.buttonTOP, "Goto End", [button5Click], UL, 254, 216, 106, 25 open "untitled" for window as #main print #main, "font ms_sans_serif 0 16"
[main.inputLoop] 'wait here for input event wait
[button1Click] 'Perform action for the button named 'button1' #main.textedit1 "!cls" 'clear first
txt$="" for i = 1 to 20 txt$=txt$+"Line ";i;chr$(13);chr$(10) next #main.textedit1 "!cls" #main.textedit1, txt$ 'printing big string at once: stays on last line wait
[button2Click] 'Perform action for the button named 'button2' #main.textedit1 "!cls" 'clear first
gosub [createfile]
open "myfile2.txt" for input as #2 print #main.textedit1, "!contents #2"; close #2
'ADDED ******************************************** [button5Click] call countlines #main.textedit1 , "!origin "; " 1 "; NumLines/2 ; '******************************************** wait
[button3Click] 'Perform action for the button named 'button3' #main.textedit1 "!cls" 'clear first
for i = 1 to 20 #main.textedit1, "Line ";i 'adding one by one: stays on last line next wait [button4Click] #main.textedit1 , "!origin 1 1 " ; wait
'ADDED ******************************************** sub countlines #main.textedit1, "!lines NumLines" ; end sub
[createfile] open "myfile2.txt" for output as #1 txt$="" for i = 1 to 20 txt$=txt$+"Line ";i;chr$(13);chr$(10) 'note just chr$(13) not enough next #1, txt$ close #1 return
|
|