EmEditor (text editor) Forum Index
   Questions and Answers about Macros
     GetLine Method get selected text only???
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 2/20/2012 11:47 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 285
Re: GetLine Method get selected text only!
Your answer implies that GetLine() returns the whole line already.

That was not clear to me because i saw different results (to my failure as i see now)


Today i saw by an another test that GetLine() returns the whole line indeed:

#language = "VBScript"

'Returns the line number of the top of the selection.
SelLineFirst = document.selection.GetTopPointY( eePosView )
	
'Returns the line number of the bottom of the selection.
SelLinesLast = document.selection.GetBottomPointY( eePosView )


For LineNumber = SelLineFirst to SelLinesLast

	'Retrieves the text on the specified line "LineNumber"
	Line = document.GetLine( LineNumber )
	
	'Show line content:
	alert Line 

        'here is my failure
        'document.selection.Text = newtext & Line

Next 'LineNumber





Now that i know that GetLine() returns the whole line content
i know i did something wrong.

My problem was that i wanted not to select the whole lines
(in front of executing my script)
but start selection at some signs behind SOL at first line
and end at some position before EOL at the last line.

BUT then, silly me, i used document.selection.Text = newtext
and was wondering why GetLine() didn't returns the whole line,
now i see i was to silly to get what happens... sorry.
(only the selected text was altered, of course)


No i use something like
For LineNumber = SelLineFirst to SelLinesLast

	'Retrieves the text on the specified line "LineNumber"
	Line = document.GetLine( LineNumber )
	
	'Selects a line at the cursor.
	document.selection.SelectLine

        'overwrite this line with new text
        document.selection.Text = newtext & Line

Next 'LineNumber



The additional document.selection.SelectLine
extends at real time the selection to the whole line
and so my replacement replaces the whole line as wanted.

Issue solved.
Thanks Yutaka! Thank you for your endurance and support!
Flat Previous Topic | Next Topic


Subject Poster Date
   GetLine Method get selected text only??? Stefan 2/18/2012 10:56 am
     Re: GetLine Method get selected text only??? Yutaka 2/20/2012 10:02 am
     » Re: GetLine Method get selected text only! Stefan 2/20/2012 11:47 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文