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 回答