Article View: comp.groupware.lotus-notes.programmer
Article #1Re: How do I add a new line to a text field via LotusScript?
From: Kirk Stoner
Date: Mon, 22 May 2023 18:39
Date: Mon, 22 May 2023 18:39
70 lines
4050 bytes
4050 bytes
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
Technical Details
Message-ID:
<6659e179-c465-40c8-8fe1-2756d553b99en@googlegroups.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mailReferences:
<843148392.19258.0@squark.demon.co.uk> <64b2fcaf-de02-4752-b562-b581f52a023e@googlegroups.com> <775f5cff-4852-4baa-bd20-1b7dcad84b0fn@googlegroups.com>Show Full Headers
Complete Article Headers
Message-ID: <6659e179-c465-40c8-8fe1-2756d553b99en@googlegroups.com> Subject: Re: How do I add a new line to a text field via LotusScript? Date: Mon, 22 May 2023 18:39:03 +0000 From: Kirk Stoner <kirkstonersystemsarchitect@gmail.com> References: <843148392.19258.0@squark.demon.co.uk> <64b2fcaf-de02-4752-b562-b581f52a023e@googlegroups.com> <775f5cff-4852-4baa-bd20-1b7dcad84b0fn@googlegroups.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail X-Received: by 2002:a05:620a:4721:b0:748:59c2:c071 with SMTP id bs33-20020a05620a472100b0074859c2c071mr3193359qkb.4.1684780743332; Mon, 22 May 2023 11:39:03 -0700 (PDT) X-Received: by 2002:a05:620a:454e:b0:759:5252:c053 with SMTP id u14-20020a05620a454e00b007595252c053mr3808879qkp.1.1684780743159; Mon, 22 May 2023 11:39:03 -0700 (PDT) Newsgroups: comp.groupware.lotus-notes.programmer In-Reply-To: <775f5cff-4852-4baa-bd20-1b7dcad84b0fn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=4.35.180.174; posting-account=ha1UnQoAAACPG0AiklAtD0pNqnspunAE Nntp-Posting-Host: 4.35.180.174 User-Agent: G2/1.0 Mime-Version: 1.0 Injection-Date: Mon, 22 May 2023 18:39:03 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable