演習 5 : データ入力と検索のオブジェクト・バージョンの記述
-
以下は、myBASdatentobj の新規 store サブルーチンです。
public sub store() ' store the data dim yn, per input "Store? (y/n): ", yn ' see if user wants to store ' only go on if user says yes if ( yn <> "y" ) then println "...not stored." exit sub end if per = New BasTutorial.Person() with per .Name = name .Phone = phone .DOB = intdob .%Save() end with per = Nothing println "...stored" ' done end sub
-
以下は、myBASlookupobj の新規 load サブルーチンです。
private sub load(id as %Integer) ' load a person into local variables dim per per = OpenId BasTutorial.Person(id) with per name = .Name phone = .Phone intdob = .DOB end with per = Nothing end sub
-
以下は、myBASlookupobj の新規 update サブルーチンです。
private sub update(id As %Integer,_ newname As %String,_ newphone As %String,_ newintdob As %Integer) ' update ^PersonD and ^PersonI dim per per = OpenId BasTutorial.Person(id) with per .Name = newname .Phone = newphone .DOB = newintdob .%Save() ' this updates indices too, all within a transaction! end with per = Nothing println "...updated." end sub
-
この行を変更して、myBASlookupobj の getphone サブルーチンを更新します。
ph = traverse(^PersonI("Phone", origph), 1, loopid)
以下のとおり変更します。
ph = traverse(^PersonI("Phone", origph)) if ph <> "" then loopid = traverse(^PersonI("Phone", ph, ""))
-
次にこの行を変更します。
loopid = ^PersonI("Phone", origph)
以下のとおり変更します。
loopid = traverse(^PersonI("Phone", origph, ""))
-
次にこの行を変更します。
ph = traverse(^PersonI("Phone", ph), 1, loopid)
以下のとおり変更します。
ph = traverse(^PersonI("Phone", ph)) if ph <> "" then loopid = traverse(^PersonI("Phone", ph, ""))