Notesってノーツと読むんだよ。

配列処理

最終更新:

bottle

- view
メンバー限定 登録/ログイン

オブジェクト変数を配列として扱う

以下の例は、クラスから派生させたオブジェクト変数自体を配列として扱った
スクリプトの一例です。
オブジェクト変数が不特定多数になるような場合には、この方法が便利かも。

スクリプト例

まず、各個人で複数のDBをプロファイル文書に登録させます。
(プロファイル文書のDBTitle・DBServer・DBFileの各フィールドは
複数値入力可能。)
其の上で、他の文書で登録したDBのリストから、
DBがあるかどうかチェックしたいDBタイトルを選択させます。
チェックされたDBタイトル名を元に、プロファイル文書内で
DBタイトル名と同じ配列位置にあるサーバ名・ファイル名を取得し、
DB自体をDB配列変数にセット。
あとはDB自体からタイトルが取れるかどうかで、
そのDBがあるかどうかをチェックし、メッセージ表示。

Dim wksp As New NotesUIWorkspace
Dim doc As NotesDocument
'--カレント文書の取得
Set doc = wksp.CurrentDocument.Document

Dim session As New NotesSession
'--プロファイル文書の取得
Dim profile As NotesDocument
Set profile = session.CurrentDatabase.GetProfileDocument_
("(SearchDBSetup)", session.UserName)

'--DBファイルパスの取得のための配列位置取得
Dim index() As Integer
Dim cnt As Integer
Forall myfile In doc.SearchDB
For i = 0 To Ubound(profile.DBTitle)
If Strcomp(myfile, profile.DBTitle(i), 4) = 0 Then
Redim Preserve index(cnt) As Integer
index(cnt) = i
cnt = cnt + 1
End If
Next
End Forall

'--DBの取得
Dim db() As NotesDatabase
Dim errstr as string
For i = 0 To Ubound(index)
Redim Preserve db(i) As NotesDatabase
Set db(i) = session.GetDatabase_
(profile.DBServer(index(i)), profile.DBFile(index(i)))
If db(i).Title = "" Then
If errstr = "" Then
errstr = profile.DBTitle(index(i))
Else
errstr = errstr + Chr(10) + profile.DBTitle(index(i))
End If
End If
Next

If errstr <> "" Then
Messagebox "アクセスできない" + Chr(10) + errstr
Exit Sub
End If

ツッコミ・コメント

名前:
コメント:

目安箱バナー