0

これは現在のコードです:

Class %Utcov.Test Extends %RegisteredObject
{

ClassMethod listClasses(ns As %String, projectName As %String)
{
    // Switch namespaces to the new one
    new $namespace
    set $namespace = ns

    // Grab our project, by name; fail otherwise
    // TODO: failing is CRUDE at this point...
    #dim project as %Studio.Project
    #dim status as %Status

    // TODO: note sure what the "concurrency" parameter is; leave the default
    // which is -1
    set project = ##class(%Studio.Project).%OpenId(projectName, /* default */, .status)

    if ('status) {
        write "Argh; failed to load", !
        halt // meh... Ugly, f*ing ugly
    }

    w project.Items
}

ClassMethod main()
{
    do ..listClasses("USER", "cache-tort-git")
}

}

まず最初に: コードがうまくいかないことはわかっています... しかし、それは学習曲線です。最終的にはもっとうまくやります... ここで解決したい問題は次の行です:

w project.Items

コンソールでは、現在次のように出力されます。

2@%Library.RelationshiptObject

しかし、私がやりたいのは、もちろんこれらのオブジェクトを循環することです。ドキュメントによれば、これらのオブジェクトは%Studio.ProjectItemの「インスタンス」です。

これらを循環するにはどうすればよいですか?WRITE実際、私は最初からそうではないだろうと推測していました...これがObjectScriptでどのように行われるのか理解できません:/

4

2 に答える 2

2

を使用してオブジェクトを書き込んだ場合、w project.Itemsそのような文字列を取得し2@%Library.RelationshiptObjectた場合、この文字列は取得したオブジェクトを理解するのに役立ちます。この場合、それはクラスのオブジェクトです。ドキュメント%Library.RelationshiptObjectでこのクラスを開くと、役立つメソッドがいくつか見つかる場合があります。あなた。ここでは、いくつかの例、リレーションシップ、オブジェクトの方法、および SQL を使用する方法を見つけることができます。

于 2016-04-21T06:20:25.937 に答える
0
Set tKey = ""
For {
    ;tItem will be the first item in your list which will be ordered by OREF
    Set tItem = project.Items.GetNext(.tKey)
    Quit:(tKey = "")
    ;Do whatever you want with tItem
}
于 2016-09-16T22:38:47.293 に答える