【问题标题】:Get GLOBALS similar to "Global Search Mask" Intersystems Cache获取类似于“全局搜索掩码”的 GLOBALS 系统间缓存
【发布时间】:2016-04-02 07:26:14
【问题描述】:

我现在可以使用 VisM 通过 vb.net 执行 Intersystem Cache Objectscript

            'open the connection
        AxVisM1.Connect("CN_IPTCP:127.0.0.1[1972]")
        'set namespace to livedata (for formal namespaces, use the @ symbol)
        AxVisM1.NameSpace = "LIVEDATA"

        'okay, so kunin mo na si GLOBALS...
        'set value to nothing muna
        AxVisM1.VALUE = ""

        'next, get mo yung value via this syntax
        AxVisM1.Code = "Set VALUE=$GET(" & theGlobals & ")"


        'execute
        AxVisM1.ExecFlag = 1

        'close the connection
        AxVisM1.DeleteConnection()

        'now, pass the results to.. a textbox?

        Return AxVisM1.VALUE

您可以通过在 .CODE 上传递 objectscript 来执行它

现在,我可以使用一个对象脚本来模拟 Intersystems Cache 中 GLOBAL SEARCH MASK 的功能吗?如下图所示

编辑我尝试了以下方法将数据传递给我的数据表,但我的数据表没有任何内容

Try
        'open the connection
        AxVisM1.Connect("CN_IPTCP:127.0.0.1[1972]")
        'set namespace to livedata (for formal namespaces, use the @ symbol)
        AxVisM1.NameSpace = "LIVEDATA"

        'okay, so kunin mo na si GLOBALS...
        AxVisM1.P1 = "^BACKTR(""INDX"",""COMPANY"",)"
        'set value to nothing muna
        AxVisM1.VALUE = ""

        ''next, get mo yung value via this syntax


        AxVisM1.Execute("set tRS=##class(%ResultSet).%New(""%Global:Get"")")
        AxVisM1.Execute("set P3=tRS.Execute(P0,P1,"""")")
        If (AxVisM1.Error <> 0) Then
            MsgBox(AxVisM1.ErrorName)
            Exit Try
        End If

        'create the datatable

        Dim tbl As New DataTable
        tbl.Columns.Add("theGlobals")
        tbl.Columns.Add("theValz")

        'start the loop
        AxVisM1.P2 = "0"
        While True
            AxVisM1.Execute("set P2=0,P3="",VALUE="" if tRS.Next() { set P2=1,P3=tRS.GetData(1),VALUE=tRS.GetData(2) } ")
            AxVisM1.ExecFlag = 1

            If (AxVisM1.Error <> 0) Then
                MsgBox(AxVisM1.ErrorName)
                Exit While
            End If
            If (AxVisM1.P2 = "0") Then
                Exit While
            End If

            ' AxVisM1.P3 - globalName
            ' AxVisM1.VALUE - data
            tbl.Rows.Add(AxVisM1.P3.ToString, AxVisM1.VALUE.ToString)


        End While
        'close the connection
        AxVisM1.DeleteConnection()


        'Return AxVisM1.VALUE
        Return tbl


    Catch ex As Exception

        'close the connection
        AxVisM1.DeleteConnection()

        MsgBox(ex.ToString)
        Return Nothing

    End Try

【问题讨论】:

    标签: vb.net intersystems-cache


    【解决方案1】:

    在这种情况下,您可以使用 %Library.Global 类和 Get 查询。在此查询中,您可以传递与第二个参数完全相同的掩码,并将获得全局名称和值作为结果。在缓存中这样的代码可能看起来像:

    Set Namespace = "USER"
    Set mask = "^BACKTR(""DATA"",,)"
    Set tRS = ##class(%ResultSet).%New("%Global:Get")
    Set tSC = tRS.Execute(Namespace,Mask,"")
    While tRS.Next() {
        Set gn = tRS.GetData(1)
        Set data = tRS.GetData(2)
    }
    

    在 VB 中是这样的

        AxVisM1.P0 = "USER"
        AxVisM1.P1 = "^BACKTR(""DATA"",,)"
    
        AxVisM1.Execute("set tRS=##class(%ResultSet).%New(""%Global:Get"")")
        AxVisM1.Execute("set P3=tRS.Execute(P0,P1,"""")")
        If (AxVisM1.Error <> 0) Then
            MsgBox(AxVisM1.ErrorName)
            Exit Try
        End If
    
        AxVisM1.P2 = "0"
        While True
            AxVisM1.Execute("set P2=0,P3="",VALUE="" if tRS.Next() { set P2=1,P3=tRS.GetData(1),VALUE=tRS.GetData(2) } ")
            If (AxVisM1.Error <> 0) Then
                MsgBox(AxVisM1.ErrorName)
                Exit While
            End If
            If (AxVisM1.P2 = "0") Then
                Exit While
            End If
    
            ' AxVisM1.P3 - globalName
            ' AxVisM1.VALUE - data
    
        End While
    

    【讨论】:

    • 同时执行不工作..我们应该每行执行吗?
    • 不确定我是否完全理解您,由于不工作,我只是从我的测试项目中复制了这些行。
    • 我已编辑问题以包含建议的代码
    • 看起来您错过了 AxVisM1.P0 并将您的命名空间作为值
    • 天哪,我非常爱你 DAiMor。
    猜你喜欢
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 2013-12-20
    • 1970-01-01
    相关资源
    最近更新 更多