本履歴

購入した古本の履歴と時々プログラミング

ロータススクリプト

ノーツからこのはてなダイアリーに書き出しするエージェント

Sub Click(Source As Button)
	Dim workspace As New NotesUIWorkspace
	Dim sess    As New NotesSession
	Dim doc As NotesDocument
	Dim tempdoc As NotesDocument
	Dim flag As Boolean
	Dim dc As NotesDocumentcollection
	Dim item As NotesRichTextItem
	Dim i As Integer	
	Dim title As String
	Dim authors As String
	Dim buyprice As String
	
	Set dc= sess.CurrentDataBase.UnprocessedDocuments
	Set doc = sess.CurrentDataBase.CreateDocument
	Set item = doc.CreateRichTextItem("blog_tag")
	
	If DC.Count<1 Then 
		Messagebox "文書が正しく選択されていません。終了します。",MB_OK,"確認" 
		Exit Sub
	End If
	
	For i = 1 To dc.Count
		Set tempdoc=dc.GetNthDocument(i)
		If tempdoc.ISBN(0) ="" Then
			title=tempdoc.ProductName(0)
		Else
			title="ISBN:" & tempdoc.ISBN(0) & ":title"			
		End If
		
		'authors = tempdoc.Authors(0)
		authors = Join(tempdoc.GetItemValue("Authors"))
		
		If tempdoc.NewOrUsed(0) ="Used" Then
			buyprice=Cstr(tempdoc.BuyPrice(0))
		Else
			buyprice=Cstr(tempdoc.SellPrice(0)	)	
		End If	
		
		Call item.AppendText("-"& title & " " & authors & " " & buyprice)
		Call item.AddNewline(1)
	Next
	Call item.Update
	flag = workspace.DialogBox("Blog_Tag",True,True,True,False,False,False,"",doc,,False)
End Sub