$bit()可以在此处创建变量



从该项目中提取的代码:

Method RefineSearch(pNewCriteria As %String) As %Status [ ZenMethod ]
{
    set tSC = $$$OK
    try {
        set ..criteria = ..criteria _$s(..criteria="":"",1:",")_pNewCriteria
        set tType = $piece(pNewCriteria,":",1)
        if tType="prop" {
            set tSQL = "SELECT ID FROM "_..tableName_" WHERE "_$piece(pNewCriteria,":",2)_" = '"_$piece(pNewCriteria,":",3)_"' AND %ID %FIND Demo_SearchPortal.Find("_..qid_")"
            set tResult = ##class(%SQL.Statement).%ExecDirect(,tSQL)
            while tResult.%Next() {
                set tID = tResult.%GetData(1)
                $$$IFBITOFFPOS(tID,tChunk,tPos)
                set $bit(tBits(tChunk),tPos)=1 // <-- HERE
            }
            // compress bitmaps
            set tMaxChunk=$order(tBits(""),-1)
            for tChunk = 1:1:tMaxChunk {
                set tBits(tChunk) = $bitlogic(tBits(tChunk))
            }
        } else {
            set tFinder = $classmethod(..className, ..indexName_"Embedded")
            if (tType = "entity") {
                do tFinder.PrepareFind("{"_$piece(pNewCriteria,":",2)_"}", ..searchMode)
            } elseif (tType = "word") {
                do tFinder.PrepareFind($piece(pNewCriteria,":",2), ..searchMode)
            }
            merge tOldBits = ^CacheTemp.IF.SearchPortal.Query(..qid,"b")
            set tChunk=""
            for {
                set tBits = tFinder.NextChunk(.tChunk)
                quit:tChunk=""
                set tBits(tChunk)=$bitlogic(tBits & tOldBits(tChunk))
            }
        }
        set tNewQID = $i(^CacheTemp.IF.SearchPortal.Query)
        merge ^CacheTemp.IF.SearchPortal.Query(tNewQID,"b") = tBits
        set ^CacheTemp.IF.SearchPortal.Query(tNewQID, "parent") = ..qid
        set ..qid = tNewQID
    } catch (ex) {
        set tSC = ex.AsStatus()
    }
    quit tSC
}

在标记为<-- HERE的位置,这是tBits的第一次出现——具有引导的下标访问权限。

这真的合法吗?

Yes $bit可以用作SET命令中的左侧函数,在这种情况下,任何合法变量也可以用作合法变量。如果该变量未定义,将获得新值。除了$bit,还有可用的$piece$extract,您可以在文档

中看到它

相关内容

  • 没有找到相关文章

最新更新