« Return to Thread: Avoiding Moving The Cursor Before Start of Document

Re: Avoiding Moving The Cursor Before Start of Document

by Bernard Marcelly :: Rate this Message:

Reply to Author | View in Thread

Hi Hal,
Message de Hal Vaughan  date 2009-06-26 08:41 :

> Sub InsertAutoMacroText
>
>     oDoc = ThisComponent
>     oCurs = oDoc.getCurrentController().getViewCursor()
>     iEnd = false
>     iCount = 0
>     Do
> 'Go back one character, then get that character and put it in a separate
> variable
> 'for comparison.
>         oCurs.goLeft(1, true)
>         sKey = oCurs.getString()
>         sChar = Left(sKey, 1)
> 'BUG: This next line throws an error if we try to use this at the start
> of a document.

Methods goLeft and goRight return a boolean True if the move could be done,
False if it failed.

if oCurs.goLeft(1, True)  then
   ' do your job
else
   ' already at start of text
end

Regards
   Bernard


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

 « Return to Thread: Avoiding Moving The Cursor Before Start of Document