$bit() 可以在这里创建变量吗?
Can $bit() create variables here?
从this project中提取的代码:
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
的第一次出现 -- 具有下标访问权限。
这真的合法吗?
是 $bit
可以用作 SET
命令中的左侧函数,在这种情况下任何合法变量,也是合法的。如果此变量未定义,将获得新值。以及 $bit
也可用 $piece
和 $extract
,你可以在 documentation
中看到它
从this project中提取的代码:
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
的第一次出现 -- 具有下标访问权限。
这真的合法吗?
是 $bit
可以用作 SET
命令中的左侧函数,在这种情况下任何合法变量,也是合法的。如果此变量未定义,将获得新值。以及 $bit
也可用 $piece
和 $extract
,你可以在 documentation