Insert comment at current location

forum.cdk (1998-2005) & forum.td.cdk (2005-2010)
Bob Finger

Insert comment at current location

Post by Bob Finger » 03 Apr 2003, 23:22

 Posted by:  Bob Finger 

Hi all,

Anyone have a quick pointer regarding inserting a comment via CDK at the
currently selected position?

Thank in advance,
-bob

Jonas Mandahl Pedersen

Re: Insert comment at current location

Post by Jonas Mandahl Pedersen » 04 Apr 2003, 11:36

 Posted by:  Jonas Mandahl Pedersen 

Try this

Set hItem = SalOutlineFirstMarked( hOutline )
Set objItem.Initialize( hOutline, hItem )
If objItem.InsertItemAfter( objItem, CDK_IT_Comment, objItem, objItem)
Call objItem.SetText( 'THIS IS MY COMMENT' )
Regards
Jonas

Bob Finger

Re: Insert comment at current location

Post by Bob Finger » 04 Apr 2003, 19:08

 Posted by:  Bob Finger 

Thanks a lot Jonas. With a few changes this did the trick. As written, it
would keep inserting the comment a zillion times, so this is what I ended up
with:

Set hItem = SalOutlineFirstMarked( hOutline )
Set bOk = objItem.Initialize( hOutline, hItem )
If bOk
Set bOk = objItem.GetParent( objParent )
If bOk
Set bOk = objItem.InsertItemAfter( objParent, CDK_IT_Comment, objItem,
objComment1 )
If bOk
Set sComment = '+++'
Call objComment1.SetText( sComment )
Set bOk = objComment1.InsertItemAfter( objParent, CDK_IT_Comment,
objComment1, objComment2 )
If bOk
Set sComment = '# ' || psInit || ' ' || psDate || ' ' || psTag
Call objComment2.SetText( sComment )
Call objComment2.SetModified( TRUE )

One other thing. I'd like to have the second comment line indented under
the first. Without having a cdkActionBlock object, I'm not sure how to do
this.

Thanks again,
-bob

Return to “td.cdk”

Who is online

Users browsing this forum: [Ccbot] and 0 guests