sexta-feira, 28 de janeiro de 2011

Máscara de campos em Jscript

/**
* Para ser utilizado no evento onKeyPress
* ex:
* CEP -> 99999-999
* CPF -> 999.999.999-99
* CNPJ -> 99.999.999/9999-99
* C/C -> 999999-!
* Tel -> (99) 9999-9999
* Hora -> 99:99:99 ou 99:99
* Número -> R$ 99.999,99
*/
function maskField(campo, sMask, event) {

var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(document.all) { // Internet Explorer
nTecla = event.keyCode;
} else { // Nestcape
nTecla = event.charCode;
}

if(nTecla == 39) return false;

sValue = campo.value;
fldLen = sValue.length;
mskLen = sMask.length;

if (nTecla >= 32) { // Caracteres acima de espaço
if (fldLen < mskLen) { if ((sMask.charAt(fldLen) != "!") && (sMask.charAt(fldLen) != "9")) { sValue = sValue + sMask.charAt(fldLen); campo.value = sValue; if ((nTecla < 48) || (nTecla > 57)) {
return false;
}
} else {
if (sMask.charAt(fldLen) == "9") {
if ((nTecla < 48) || (nTecla > 57)) {
return false;
}
}
}
return true;
} else {
return false;
}
} else { // Caracteres de controle
return true;
}

}







/**
* Use o evento onKeyPress para executar esta função
* ex.:
*
* @param field campo a ser mascarado
* @param maxCharBeforDecimal maximo de caracteres antes da virgula, incluindo os pontos separadores de milhar
* @param event evento do teclado capturado
*
*/
function validateKeyNumber(field, maxCharBeforDecimal, event) {
var valor = field.value
var key;

if(document.all) { // Internet Explorer
key = event.keyCode;
}
else { // Nestcape
key = event.charCode;
}

if (key == 44) {
if (valor == '') {
return false;
}
else if (findVirgula(valor)) {
return false;
}
}
else if (key < 48 || key > 57) {
if (key > 0) {
return false;
}
}

if (valor.length == maxCharBeforDecimal && !findVirgula(valor)) {
if(key != 44 && key != 0) {
return false;
}
}

if (valor.length == 1 && valor.substring(0, 1) == '0') {
if(key != 44 && key != 0) {
return false;
}
}

if (findVirgula(valor)) {
lastCharacter = valor.substring(valor.length - 1, valor.length);

if (lastCharacter != ',') {
index = valor.indexOf(',');
decimal = valor.substring(index + 1, valor.length);

if (decimal.length == 2 && key != 0) {
return false;
}
}
}
return true;
}




/**
* Use o evento onKeyUp para executar esta função
* ex.:
*
* @param field campo a ser mascarado
* @param event evento do teclado capturado
*
*/
function formatMoney(field, event) {
var key;
var valor = field.value;

if(document.all) { // Internet Explorer
key = event.keyCode;
}
else { // Nestcape
key = event.charCode;
}

if (valor.length >= 3 && valor.substring(0, 1) == '0') {
if (valor.substring(1, 2) != ',') {
field.value = valor.substring(1, valor.length)
}
}

if (valor.length > 0 && valor.substring(0, 1) == ',') {
field.value = valor.substring(1, valor.length)
}

if (key != 36 && key != 37 && key != 39 && key != 38 && key != 40 ) {
formatNumber(field)
}

return true;
}

function findVirgula(pDado) {
if(pDado.indexOf(',') > -1) {
return true
}

return false
}

function formatNumber(field) {
dec = ''
arrNum = new Array()
valor = field.value

if (findVirgula(valor)) {
indVirg = valor.indexOf(',')
dec = valor.substring(indVirg, valor.length)
valor = valor.substring(0, indVirg)
}

valor = removePoint(valor)

if (dec != '' && dec.indexOf('.') > -1) {
dec = removePoint(dec)
}

div = valor / 1000

if (div >= 1) {
j = 0

for(i = valor.length; i > 0; i = i - 3) {
if (i - 3 > 0) {
aux = valor.substring(i - 3, i)
arrNum[j++] = '.' + aux
} else {
aux = valor.substring(0, i)
arrNum[j++] = aux
}
}
formattedValue = '';

for(k = j - 1; k >= 0; k--) {
formattedValue += arrNum[k]
}

field.value = formattedValue + dec
}
else {
field.value = valor + dec
}
}

function removePoint(value) {
for(j = 0; j < value.length; j++) { if (value.indexOf('.') > 0) {
j = value.indexOf('.')
aux1 = value.substring(0, j)
aux2 = value.substring(j + 1, value.length)
value = aux1 + aux2
}
}

return value
}

/**
* Use esta função no evento onblur
* ex.:
*
* @param textField campo a ser mascarado
*
*/
function formatDecimal(textField) {
value = textField.value;
indVirg = value.indexOf(',');
isEmpty = value == '';

if (isEmpty) {
return true;
}
if (indVirg == -1) {
value = value + ',00';
textField.value = value;
}
else if (indVirg == value.length - 1) {
value = value + '00';
textField.value = value;
}
else {
decimal = value.substring(indVirg + 1, value.length);

if (decimal.length < 2) { textField.value = value + '0'; } } } /** * Use esta função no evento onblur * ex.:
*
* @param textField campo a ser mascarado
*
*/
function formatDecimal1(textField) {
value = textField.value;
indVirg = value.indexOf(',');
isEmpty = value == '';

if (isEmpty) {
return true;
}
if (indVirg == -1) {
value = value + ',0';
textField.value = value;
}
else if (indVirg == value.length - 1) {
value = value + '0';
textField.value = value;
}
}

sexta-feira, 21 de janeiro de 2011

Gerar PDF a partir de um notesdocument

%REM
Versões anteriores a 7, deve executar o agente com RunOnSeerver
Ambiente nesta solução:
Trab. com um documento SALVO no client Notes e precisava exportar os textos para impressão.
A imagem anexada no cabeçhalho encontra-se em um documento notes que é setado em outra visão.
Para isso foi criado um agente(list Selection / target:none) com o código abaixo:
%END REM


import java.awt.Color;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;

import lotus.domino.Agent;
import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.DateTime;
import lotus.domino.Document;
import lotus.domino.EmbeddedObject;
import lotus.domino.MIMEEntity;
import lotus.domino.MIMEHeader;
import lotus.domino.NotesException;
import lotus.domino.RichTextItem;
import lotus.domino.Session;
import lotus.domino.Stream;
import lotus.domino.View;

import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

//import com.lowagie.text.*;
//import com.lowagie.text.pdf.*;


public class JavaAgent extends AgentBase {

public void NotesMain() {

try {

Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
Agent agent = agentContext.getCurrentAgent();
//System.out.println(agent.getParameterDocID());
Document doc = db.getDocumentByID(agent.getParameterDocID());

String id = doc.getUniversalID();
String filename = id+".pdf";


ByteArrayOutputStream os = new ByteArrayOutputStream(); //( PageSize.A4,esq uerda,direita,topo,rodapé)
com.lowagie.text.Document document = new com.lowagie.text.Document(PageSize.A4,35,35,10,35);

PdfWriter.getInstance(document, os);

String strDataTopo = "";

document.open();
document.newPage();


/***************************** MONTANDO O PDF ****************************/

//seta a visão
View visao = db.getView("vwLogo");
// seta o documento com o Logo
lotus.domino.Document docLogo = visao.getDocumentByKey("img_imagem.JPG", true);


//verifica se o documento foi setado corretamente
if (docLogo!=null){

//seta o path do anexo (campo texto)
String filepath = docLogo.getItemValueString("ASName"); //ca_labelAnexo
//seta o nome do anexo
String filesname = filepath.substring(filepath.lastIndexOf("/")+1);
//seta o anexo através do nome
EmbeddedObject file = docLogo.getAttachment(filesname);
//seta o anexo como streaming
InputStream is = file.getInputStream();

//read the inputstream in to a bytearray to pass to PDF image instance
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = is.read(buf)) > 0) {
bos.write(buf, 0, len);
}
byte[] data = bos.toByteArray();

//seta o logo
Image logo = Image.getInstance(data); /* imagem setada e convertida**/

/*************** *montando o pdf **********/

// seta o campo data p/inserir no cabeçalho

try {
strDataTopo = (new SimpleDateFormat("dd/MM/yyyy")).format(((DateTime)doc.getItemValueDateTimeArray("ca_alert_data").firstElement()).toJavaDate()).toString();
} catch (NotesException e) {
strDataTopo ="";
}


//cria o cabeçalho
float[] widths1 = { 1.25f, 2.25f, 1.75f };

PdfPTable table = new PdfPTable(widths1); // 3 é referente ao número de colunas
PdfPCell c1 = new PdfPCell();
c1.setImage(logo); // <= inseri o logo na primeira coluna
c1.setBorderColor(new Color(255,255,255)); // Cor da borda da celula
c1.setHorizontalAlignment(Element.ALIGN_BOTTOM); //alinhamento Horizontal
c1.setVerticalAlignment(Element.ALIGN_BOTTOM); //alinhamento Vertical
table.addCell(c1); //inseri a célula na tabela

c1 = new PdfPCell(new Phrase("RESERVADO"));
c1.setHorizontalAlignment(Element.ALIGN_CENTER); //alinhamento Horizontal
c1.setVerticalAlignment(Element.ALIGN_BOTTOM); //alinhamento Vertical
c1.setBorderColor(new Color(255,255,255)); // Cor da borda da celula
table.addCell(c1); //inseri a célula na tabela

c1 = new PdfPCell(new Phrase(strDataTopo));
//c1 = new PdfPCell(new Phrase(strDataTopo));
c1.setHorizontalAlignment(Element.ALIGN_RIGHT); //alinhamento Horizontal
c1.setVerticalAlignment(Element.ALIGN_BOTTOM); //alinhamento Vertical
c1.setBorderColor(new Color(255,255,255)); // Cor da borda da celula
table.addCell(c1); //inseri a célula na tabela

// com a tabela com 100% da definição da pagina
table.setWidthPercentage(100);
//adiciona a tabela no document
document.add(table); //inseri a tabela no documento ( pdf )
}
//FIM - cria o cabeçalho


Paragraph myParagraph = new Paragraph( "ALERTA REGIONAL" , new Font(Font.HELVETICA, 10, Font.BOLD));
myParagraph.setAlignment(Element.ALIGN_LEFT);
document.add( myParagraph );
document.add( new Paragraph(" ") );

Paragraph myParagraph2 = new Paragraph( "SEGURANÇA EMPRESARIAL | CONTATO: GDN1" , new Font(Font.HELVETICA, 8, Font.NORMAL));
myParagraph2.setAlignment(Element.ALIGN_RIGHT);
document.add( myParagraph2 );
document.add( new Paragraph(" ") );

Paragraph myParagraph3 = new Paragraph( "Regional: " + doc.getItemValueString("ca_alert_regional") , new Font(Font.HELVETICA, 8, Font.NORMAL));
myParagraph2.setAlignment(Element.ALIGN_LEFT);
document.add( myParagraph3 );
document.add( new Paragraph(" ") );


PdfPTable table2 = new PdfPTable(1); // 3 é referente ao número de colunas
// com a tabela com 100% da definição da pagina
table2.setWidthPercentage(100);
PdfPCell c1 = new PdfPCell();

RichTextItem rti = (RichTextItem)doc.getFirstItem("ca_alert_titulo");
c1.addElement( new Paragraph( new Paragraph( rti.getUnformattedText(),new Font(Font.HELVETICA, 8, Font.NORMAL)))) ;
c1.setBorderColor(new Color(255,255,255)); // Cor da borda da celula
c1.setBackgroundColor(new Color(225,225,225)); // Cor da borda da celula
c1.setHorizontalAlignment(Element.ALIGN_LEFT); //alinhamento Horizontal
table2.addCell(c1); //inseri a célula na tabela
document.add(table2);


RichTextItem rti2 = (RichTextItem)doc.getFirstItem("ca_alert_corpo");
document.add( new Paragraph( rti2.getUnformattedText(),new Font(Font.HELVETICA, 8, Font.NORMAL)) );
document.add( new Paragraph(" ") );


document.close();

/***************************** CRIA O DOCUMENTO TEMPORÁRIO COM O ANEXO ****************************/

Document docTemp = db.createDocument();
docTemp.appendItemValue("Form", "Frm_TempAnexo");
docTemp.appendItemValue("ca_docId_docPai",doc.getUniversalID());
docTemp.appendItemValue("ca_Author",session.getUserName());
docTemp.appendItemValue("ca_excluir","0");
docTemp.save(true,true);


//Put the contents of the text field in to a Notes Stream!
Stream stream=session.createStream();
stream.write( os.toByteArray() );

//Attach file here
if ( !docTemp.isNewNote() )
docTemp.removeItem("Files");

MIMEEntity m = docTemp.createMIMEEntity("Files"); //if no param -- creates a field called Body (so one can't already be on form!)

MIMEHeader header = m.createHeader("content-disposition");
header.setHeaderVal("attachment;filename=\""+filename+"\"");

m.setContentFromBytes(stream, "application/pdf", MIMEEntity.ENC_IDENTITY_BINARY); //ENC_BASE64);
m.decodeContent();


//Following call to doc.save() is NEEDED to commit the MIME to the doc
//even when we're in a WQS doc. Weird?!
//To allow Anonymous users to do so we need to add them to an Authors field (see Form). Even weirder.
docTemp.save(true, true);





} catch(Exception e) {
e.printStackTrace();
}
}
}

Compactar arquivos com Notes 6

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci1002690,00.html

LotusScript does not have a native class for compressing files to .zip format. In this tip, I'll show you how change that, if you are running Notes or Domino R6 (or newer), by using the ability of LotusScript to make calls to functionality that is available in the Java language. This is done using LS2J -- which is documented in Designer Help.
I have an agent that holds the following code in Initialize:
Sub Initialize
Dim js As JAVASESSION
Dim zipClass As JAVACLASS
Dim zipFileObject As JavaObject
Dim varFileToZip As String, varOutFilePath
As String, returnCode As String

Set js = New JAVASESSION
Set zipClass = js.GetClass("ZipFile")
Set zipFileObject = zipClass.CreateObject
varFileToZip = "c:tempdocument.doc"
varOutFilePath = "c:tempthezipfile.zip"

returnCode = zipFileObject.zipMyFile
(varFileToZip, varOutFilePath)
'Calling the zip function

If Not returnCode = "OK" Then
Print "An Error occurred"
Else
Print "Zip went OK"
End If
End Sub

In the Options of the agent I have the following:
Uselsx "*javacon" 'Which lets you use
Java from LotusScript
Use "ZipFile" 'A Java library that holds
a function to do zipping

Below is the Java Library that makes it possible to zip a file. You create a Java Library in the Designer in Shared code -> Script Libraries, click New Java Library, remove the few lines of code that you get as a help for getting started, and paste the code below. Save and call the library "ZipFile."
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class ZipFile {
public String zipMyFile(String fileToZip,
String zipFilePath) {
String result = "";

byte[] buffer = new byte[18024];

// Specify zip file name
String zipFileName = zipFilePath;

try {

ZipOutputStream out =
new ZipOutputStream
(new FileOutputStream(zipFileName));

// Set the compression ratio
out.setLevel
(Deflater.BEST_COMPRESSION);

System.out.println(fileToZip);
// Associate a file input stream
for the current file
FileInputStream in =
new FileInputStream(fileToZip);

// Add ZIP entry to output stream.
out.putNextEntry
(new ZipEntry(fileToZip));

// Transfer bytes from
the current file to the ZIP file
//out.write(buffer, 0, in.read(buffer));

int len;
while ((len = in.read(buffer)) > 0)
{
out.write(buffer, 0, len);
}

// Close the current entry
out.closeEntry();

// Close the current file input stream
in.close();

// Close the ZipOutPutStream
out.close();
}
catch (IllegalArgumentException iae) {
iae.printStackTrace();
return "ERROR_
ILLEGALARGUMENTSEXCEPTION";
}
catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
return "ERROR_FILENOTFOUND";
}
catch (IOException ioe)
{
ioe.printStackTrace();
return "ERROR_IOEXCEPTION";
}


return "OK";

}
}

Credit goes to this article that helped me get zipping to work: Zip meets Java from Devshed.

Extrair arquivos com Java

link: http://www.devshed.com/c/a/Java/Zip-Meets-Java/2/

So we can create zip files with Java. Can we extract them? Listing 2 shows an example Java class that can do just that. Let’s cover what’s going on in the class, as it might not be that obvious to the java.util.zip API newcomer.

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipUncompressExample
{

   // specify buffer size for extraction
   static final int BUFFER = 2048;

   public static void main(String[] args)
   {
     try
     {
       System.out.println("Example of ZIP file decompression.");

       // Specify file to decompress
       String inFileName = "c:\example.zip";
       // Specify destination where file will be unzipped
       String destinationDirectory = "c:\temp\";

       File sourceZipFile = new File(inFileName);
       File unzipDestinationDirectory = new File(destinationDirectory);

       // Open Zip file for reading
       ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);

       // Create an enumeration of the entries in the zip file
       Enumeration zipFileEntries = zipFile.entries();

       // Process each entry
       while (zipFileEntries.hasMoreElements())
       {
         // grab a zip file entry
         ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();

         String currentEntry = entry.getName();
         System.out.println("Extracting: " + entry);

         File destFile =
           new File(unzipDestinationDirectory, currentEntry);

         // grab file's parent directory structure
         File destinationParent = destFile.getParentFile();

         // create the parent directory structure if needed
         destinationParent.mkdirs();

         // extract file if not a directory
         if (!entry.isDirectory())
         {
           BufferedInputStream is =
             new BufferedInputStream(zipFile.getInputStream(entry));
           int currentByte;
           // establish buffer for writing file
           byte data[] = new byte[BUFFER];

           // write the current file to disk
           FileOutputStream fos = new FileOutputStream(destFile);
           BufferedOutputStream dest =
           new BufferedOutputStream(fos, BUFFER);

           // read and write until last byte is encountered
           while ((currentByte = is.read(data, 0, BUFFER)) != -1)
           {
             dest.write(data, 0, currentByte);
           }
           dest.flush();
           dest.close();
           is.close();
         }
       }
       zipFile.close();
     }
     catch (IOException ioe)
     {
     ioe.printStackTrace();
     }
   }
}

The ZipUncompressExample class unzips a file called example.zip and extracts it to a destination directory called d:temp. We first open the source zip file. From our ZipFile object, we can use the entires() method to obtain an Enumeration which contains ZipEntry objects. These individual ZipEntry objects represent the entries which make up the Zip file.

I then use a while loop to cycle through the entries of our Zip file. As we process each ZipEntry object, we have to check and see if the zip entry in question has the needed housing directory structure in place. If the needed directories are not created, they are established. We use the getParentFile method of the File class to obtain the parent directory structure. If the current zip entry is not a directory (i.e., a file), we write the file to disk in the corresponding housing directory. This process is continued until each entry in the Zip file is processed.

Copiar campos RichText para de um documento para outro

http://moorthidaniel.com/lotus-script/copy-richtextitem-from-one-document-to-another-document/
 
%REM
Function updateRTitem
Description: Copy RichTextItem from One document to Another document
newdoc - destination document
refdoc - Source document
rtName - RichText Field name to copy
%END REM
Function updateRTitem(newdoc As NotesDocument,refdoc As NotesDocument,rtName As String)
On Error GoTo handleError
Dim srcRTitem As NotesRichTextItem
Set srcRTitem = refdoc.Getfirstitem(rtName)
Dim nav As NotesRichTextNavigator
 

Verificar se o campo RichText esta vazio - How to check Rich Text field is empty or not

http://moorthidaniel.com/lotus-script/how-to-check-rich-text-field-is-empty-or-not/


here are several ways to validate a rich text field is empty or not. Here I have listed some of them.
Method 1.
The below method will work only for the rich text fields having only texts. If the field having attachments or links it wont work
Dim session As New NotesSession
Dim ws As NotesUIWorkspace
Set ws = New NotesUIWorkspace
 
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
 
Dim doc As NotesDocument
Dim item As NotesItem
 
Set doc = uidoc.Document
 
Set item = doc.GetFirstItem("Body")
Dim valStr As String
valStr$ = item.Abstract(80, True, False)
If (Fulltrim(valStr$) = "") Then
Msgbox "empty"
Else
Msgbox valStr$
End If
Mehtod 2
This method will work fine for attachments or links and even for imported images. Here we need the document should be in edit document
' Document should be in edit mode
On Error Goto ProcessError
Dim session As New NotesSession
Dim ws As NotesUIWorkspace
Set ws = New NotesUIWorkspace
 
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
 
currentfield = uidoc.CurrentField
If uidoc.EditMode = False Then
Msgbox "Document Should be in edit mode"
Exit Sub
End If
Call uidoc.GotoField("body")
Call uidoc.SelectAll
'This line will generate a 4407 error message if the Rich Text Field is null
Call uidoc.DeselectAll
Exit Sub
processError:
If Err = 4407 Then
Messagebox "RTF Field is empty"
Else
Msgbox Error & " - errno : " & Cstr(Err) & " @ line no - " & Cstr(Erl)
End If
Method 3
This method will fail only for imported images into rich text fields.
 
Sub Click(Source As Button)
'On Error Goto ProcessError
Dim session As New NotesSession
Dim ws As NotesUIWorkspace
Set ws = New NotesUIWorkspace
 
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
 
Dim doc As NotesDocument
Set doc = uidoc.Document
 
Dim body As NotesRichTextItem
 
Set body = doc.GetFirstItem ( "Body" )
 
If ( richTextFieldEmpty ( body ) ) Then
 
If ( uidoc Is Nothing ) Then
Else
Msgbox "Please enter the Content", MB_OK + MB_ICONSTOP, "Field Contains Incorrect Value"
Call uidoc.GoToField ( "Body" )
End If
 
validateRequiredFields = False
Exit Sub
 
Else
Print "Rich Text Field not empty"
End If
 
Exit Sub
ProcessError:
Msgbox Error & " - errno : " & Cstr(Err) & " @ line no - " & Cstr(Erl)
End Sub
 
Function richTextFieldEmpty ( rti As NotesRichTextItem ) As Boolean
 
Dim rtNav As NotesRichTextNavigator
 
On Error Goto errorHandler
 
richTextFieldEmpty = False
 
If ( rti Is Nothing ) Then
Print "Rich Text Field does not exist"
richTextFieldEmpty = True
Exit Function
End If
 
Set rtNav = rti.CreateNavigator
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_TABLE ) ) Then
Print "Table found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_TEXTRUN ) ) Then
Print "Text run found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_TEXTPARAGRAPH ) ) Then
Print "Text paragraph found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_DOCLINK ) ) Then
Print "Doclink found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_SECTION ) ) Then
Print "Section found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_TABLECELL ) ) Then
Print "Table cell found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_FILEATTACHMENT ) ) Then
Print "Attachment found in rich text field"
Exit Function
End If
 
If ( rtNav.FindFirstElement ( RTELEM_TYPE_OLE ) ) Then
Print "OLE object found in rich text field"
Exit Function
End If
 
richTextFieldEmpty = True
 
endOfCode:
Exit Function
 
errorHandler:
 
'displayError ( Getthreadinfo (1) )
 
Error Err, Error$ '-- Throw Error back to invoking code
 
Resume endOfCode
 
End Function

Setar o diretório temporário no Linux/Windows/Mac

http://moorthidaniel.com/lotus-script/how-to-get-lotus-notes-temporary-directory/

Using lotus script you can get the temporary directory used by notes. Irrespective of  the OS(windows or mac or linux) used for lotus notes, by using following code it is achievable.
 
' Add below code in declaration section
 
Declare Function w32_OSGetSystemTempDirectory Lib "nnotes" Alias "OSGetSystemTempDirectory" ( ByVal S As String) As Integer
Declare Function mac_OSGetSystemTempDirectory Lib "NotesLib" Alias "OSGetSystemTempDirectory" ( ByVal S As String) As Integer
Declare Function linux_OSGetSystemTempDirectory Lib "libnotes.so" Alias "OSGetSystemTempDirectory" ( ByVal S As String) As Integer
Const ERR_UNSUPPORTED_PLATFORM = 20300 ' or other value you choose.
 
' Add below function
' this function GetNotesTempDirectory() will return the temporary directory used by lotus notes.
 
Function GetNotesTempDirectory() As String
' Returns the path of the temporary directory used by Notes.
Dim session As New NotesSession
Dim d As String * 256
Dim s%
Select Case session.Platform
Case "Linux"
s% = linux_OSGetSystemTempDirectory(d)
Case "Macintosh"
s% = mac_OSGetSystemTempDirectory(d)
Case "Windows/32"
s% = w32_OSGetSystemTempDirectory(d)
Case Else
Error ERR_UNSUPPORTED_PLATFORM, "In GetNotesTempDirectory, platform not supported: " & session.Platform
End Select
GetNotesTempDirectory = Left$(d, s%)
End Function