-2

I need to save some text while lotus notes client is open. If user closes notes client then this text must be deleted

Ruslan280
  • 1
  • 1

1 Answers1

2

There may be a much easier way, but this is the only way I can think of that guarantees that you can clear the text every time Notes starts.

When you start the Notes client, a file called pid.nbf is created or updated. It is a text file, and each line contains information about the different executable programs that are running. One of the lines will contain information for nlnotes.exe, which is the main executable. The second column of each line contains the process id, which will be different every time you run Notes. You can write LotusScript code to read the file and find the process id, and use this identifier to distinguish the text from different sessions. I'm just going to assume you've done that, and you've got it in a LotusScript variable named 'pid', and you've got the text you want to save in a variable named 'theText'. I'll also assume your NotesSession variable is called 'session'.

If it's a small amount of text, you can use this to save the text:

session.SetEnvironment("MySavedText",pid + "!!" + theText,true) 

To read the text, you would use

theText = session.GetEnvironmentString("MySavedText",true)

After you read it, you could use this to decide if the text is from the current session:

dim splitText as variant 
splitText = split(theText,"!!")
if splitText(0) = pid then
' it's from this session
else
' it's from a previous session, so clear it
    session.SetEnvironment("MySavedText",pid + "!!" + theText,true) 
end if

The max for Notes.ini variables is 255 characters, and I think that includes the variable name, so you'd only be able to store ~240 characters of text this way,

If you need more than that, you can create a MYText.txt file on disk, or you can create a profile document in an NSF file of your choosing, use pdoc = db.getProfileDocument to access it and then use standard Notes calls pdoc.getItemValue() and pdoc.relaceItemValue on two fields named "pid" and "myText".

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • Note that I didn't test any of the above. There may be typos, etc. – Richard Schwartz Nov 20 '15 at 20:36
  • Very cool approach! And a lot of work for such a bad question. Chapeau. And for longer values you could even use profile documents or other "container"- documents.. – Tode Nov 23 '15 at 06:22