getPrevDocument (NotesDocumentCollection - JavaScript)

コレクション内で現在の文書または指定された文書の、直前の文書を取得します。

定義場所

NotesDocumentCollection

構文

getPrevDocument() : NotesDocument

getPrevDocument(doc:NotesDocument) : NotesDocument

パラメータ 説明
doc コレクション内の任意の文書。NULL にすることはできません。
戻り値 説明
NotesDocument パラメータを指定しない場合、現在の文書の直前の文書を返します。パラメータを指定した場合は、指定された文書の直前の文書を返します。直前の文書がない場合は NULL を返します。

使用法

お勧めするループ構造は、NULL が返されるまで getLastDocument() とそれに続けて getPrevDocument() を使用する方法です。 パフォーマンス上の理由から、getNthDocument(n:int)getPrevDocument(doc:NotesDocument) をループ内で使用しないでください。

ループ内で文書を取得すると、動的メモリをすぐに使い尽くしてしまいます。 メモリ問題を避けるには、var tmpdoc = getPrevDocument(); doc.recycle(); doc = tmpdoc のようなシーケンスを使用して、反復ごとに NotesDocument オブジェクトをリサイクルします。

このボタンは、逆順で現在のデータベース内にある文書をすべて取得します。
var dc:NotesDocumentCollection = database.getAllDocuments();
var doc:NotesDocument = dc.getLastDocument();
while (doc != null) {
	requestScope.status += "¥n" + doc.getItemValueString("subject");
	var tmpdoc:NotesDocument = dc.getPrevDocument();
	doc.recycle();
	doc = tmpdoc;
}
以下のボタンは、現在のデータベース内にある最後から 2 番目の文書を取得します。
var dc:NotesDocumentCollection = database.getAllDocuments();
if (dc.getCount() > 1) {
	var doc:NotesDocument = dc.getPrevDocument(dc.getLastDocument());
	requestScope.status = doc.getItemValueString("subject");
	doc.recycle();
}

言語間の参照

LotusScript® NotesDocumentCollection クラスの GetPrevDocument メソッド

Java™ DocumentCollection クラスの getPrevDocument メソッド