🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.groupware.lotus-notes.programmer
1 messages
1 total messages Started by Kirk Stoner Mon, 22 May 2023 18:39
Re: How do I add a new line to a text field via LotusScript?
#1
Author: Kirk Stoner
Date: Mon, 22 May 2023 18:39
70 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads