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

Re: Avoiding Moving The Cursor Before Start of Document

by Hal Vaughan-2 :: Rate this Message:

Reply to Author | View in Thread


On Jun 27, 2009, at 5:12 AM, Bernard Marcelly wrote:

> 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

Thanks!  I see that now, but I've got the code in to check the length  
-- there was a delay in my emails going through, so we have a lag time  
here.  I have it working with a length check for now.  I may switch to  
this, since it's more concise, but I generally avoid re-writing  
whenever I can.  I wish I had seen this before I wrote my patch!



Hal

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

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