Groups | Search | Server Info | Login | Register


Groups > comp.groupware.lotus-notes.programmer > #110

Re: How do I add a new line to a text field via LotusScript?

Newsgroups comp.groupware.lotus-notes.programmer
Date 2023-05-22 11:39 -0700
References <843148392.19258.0@squark.demon.co.uk> <64b2fcaf-de02-4752-b562-b581f52a023e@googlegroups.com> <775f5cff-4852-4baa-bd20-1b7dcad84b0fn@googlegroups.com>
Message-ID <6659e179-c465-40c8-8fe1-2756d553b99en@googlegroups.com> (permalink)
Subject Re: How do I add a new line to a text field via LotusScript?
From Kirk Stoner <kirkstonersystemsarchitect@gmail.com>

Show all headers | View raw


On Monday, May 22, 2023 at 1:35:06 PM UTC-5, Kirk Stoner wrote:
> On Monday, October 17, 2016 at 4:14:46 PM UTC-5, mer...@gmail.com wrote: 
> > On Thursday, September 19, 1996 at 1:00:00 AM UTC-6, Alastair Booker wrote: 
> > > Hi, 
> > > 
> > > I have a LotusScript macro that makes changes to a document. In amongst these 
> > > changes, I wish to add a value to the start of a text field, but on a new line 
> > > in that text field rather than just appended straight to what's already there. 
> > > 
> > > I'm currently trying with this: 
> > > 
> > > doc.Edit_History = "Change: " + Format$(Now(),"dd/mm/yy hh:mm:ss") + Chr$(13) + 
> > > Chr$(10) + doc.Edit_History(0) 
> > > 
> > > But... the CR and LF get replaced by strange block characters after this has 
> > > been run. Also, any new lines already in the text field (placed there by 
> > > @NewLine from a formula-based macro) are changed to these characters... 
> > > 
> > > Any ideas? 
> > > 
> > > Thanks, 
> > > 
> > > - Ali 
> > > 
> > > (a...@squark.demon.co.uk) 
> > This answer comes after 10 year. Was doubtful whether to post it.. But someone else may be benefited. 
> > 
> > The following code will insert a line before and after insertion text. 
> > 
> > uidoc.InsertText Chr$(10) & insertionText & Chr$(10) 
> > 
> > I tried different combinations before arriving at this. 
> > 
> > Thank you 
> > Mert
> As @Alastair Booker is using the NotesDocument class (not NotesUiDocument), there are two ways to accomplish this: 
> 1. Already stated: use of an Array but this is a bit simpler: 
> Dim newHistory(0) As String 
> newHistory(0) = "My new value to add to the end" 
> Call doc.ReplaceItemValue("Edit_History", ArrayAppend(doc.GetItemValue("Edit_History"), newHistory)) 
> 2. Use the NoteItem Class: 
> Dim item As NotesItem 
> Set item = doc,GetFirstItem("Edit_History") 
> Call item.AppendToTestList("My new value to add to the end") 
> 
> Method #1 provides the ability to "PrePend" values to the top of the list by reversing the order in ArrayAppend: 
> Dim newHistory(0) As String 
> newHistory(0) = "My new value to add to the end" 
> Call doc.ReplaceItemValue("Edit_History", ArrayAppend(newHistory, doc.GetItemValue("Edit_History"))) 
> 
> Kirk
Auto-misspell correction for solution #2:
Call item.AppendToTestList(...) -> Call item.AppendToTextList(...)
Plain old typo correction:
doc,GetFirstItem -> doc.GetFirstItem

Back to comp.groupware.lotus-notes.programmer | PreviousPrevious in thread | Find similar


Thread

Re: How do I add a new line to a text field via LotusScript? mervint@gmail.com - 2016-10-17 14:14 -0700
  Re: How do I add a new line to a text field via LotusScript? Kirk Stoner <kirkstonersystemsarchitect@gmail.com> - 2023-05-22 11:35 -0700
    Re: How do I add a new line to a text field via LotusScript? Kirk Stoner <kirkstonersystemsarchitect@gmail.com> - 2023-05-22 11:39 -0700

csiph-web