Difference between revisions of "Programming with the VPE code library"
From VistApedia
(→SELECT (Generic Lister)) |
(→SELECT^%ZVEMKT (Generic Lister)) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
− | === LIST (Generic Lister) === | + | === LIST^%ZVEMKT (Generic Lister) === |
− | |||
+ | === SELECT^%ZVEMKF -- generic selecter === | ||
− | + | (different from SELECT^%ZVEMKT) | |
− | |||
− | |||
Examples: | Examples: | ||
Line 26: | Line 24: | ||
out, and the results are stored in ^TMP("VPE","FIELDS",$J,*) | out, and the results are stored in ^TMP("VPE","FIELDS",$J,*) | ||
+ | |||
+ | === SELECT^%ZVEMKT (Generic Lister) === | ||
Here is some code that uses the VPE Selector tool. It is just a wrapper | Here is some code that uses the VPE Selector tool. It is just a wrapper | ||
− | + | '''Selector(pArray,pResults,Header)''' | |
;"Purpose: Interface with VPE Selector code to select from an array | ;"Purpose: Interface with VPE Selector code to select from an array | ||
;"Input: pArray -- NAME OF array holding items to be selected from | ;"Input: pArray -- NAME OF array holding items to be selected from | ||
Line 62: | Line 62: | ||
if $get(Header)'="" set @ref@("HD")=Header | if $get(Header)'="" set @ref@("HD")=Header | ||
+ | ;"Note: Rules of use: | ||
+ | ;" ref must=^TMP("VEE",$J) | ||
+ | ;" Each line should be in this format: | ||
+ | ;" @ref@(number)=ReturnValue_$char(9)_DisplayValue | ||
+ | ;" @ref@(number)=ReturnValue_$char(9)_DisplayValue | ||
+ | ;" @ref@(number)=ReturnValue_$char(9)_DisplayValue | ||
+ | ;" Results come bac in: | ||
+ | ;" ^TMP("VPE","SELECT",$J) | ||
D SELECT^%ZVEMKT(ref) | D SELECT^%ZVEMKT(ref) | ||
Latest revision as of 18:08, 23 September 2006
Programming with the VPE code library
Started 7/24/2006 by K Toppenberg
I'll use this to capture notes:
The code library is in the %ZVEM namespace. The source files are stored in _ZVEM*.m on GT_M
The %ZVEMKT* modules contain the code for the scrollable display/selector.
LIST^%ZVEMKT (Generic Lister)
SELECT^%ZVEMKF -- generic selecter
(different from SELECT^%ZVEMKT)
Examples:
do SELECT^%ZVEMKTF(50,"TOP") will allow a user to select (by toggling with the space key) a list of fileman fields from file 50. [ESC] will jump out, and the results are stored in ^TMP("VPE","FIELDS",$J,*)
SELECT^%ZVEMKT (Generic Lister)
Here is some code that uses the VPE Selector tool. It is just a wrapper
Selector(pArray,pResults,Header)
;"Purpose: Interface with VPE Selector code to select from an array ;"Input: pArray -- NAME OF array holding items to be selected from ;" Expected format: ;" @pArray@("Display Words")=ReturnValue <-- optional ;" @pArray@("Display Words")=ReturnValue ;" @pArray@("Display Words")=ReturnValue ;" pResults -- NAME OF array to have results returned in ;" ** Note: Prior will NOT be KILLED first ;" Format of returned array: ;" Only those valuse that user selected will be returned ;" @pResults@("Display Words")=ReturnValue <-- ptional ;" @pResults@("Display Words")=ReturnValue ;" @pResults@("Display Words")=ReturnValue ;" Header -- OPTIONAL -- A header text to show. new ref set ref=$name(^TMP("VEE",$J)) kill @ref if $get(pArray)="" goto SelDone if $get(pResults)="" goto SelDone
;"First set up array of options new DispWords,RtnValue new order set order=1 set DispWords=$order(@pArray@("")) if DispWords'="" for do quit:(DispWords="") . set RtnValue=$get(@pArray@(DispWords),"<NONE>") . set @ref@(order)=RtnValue_$char(9)_$extract(DispWords,1,$get(IOM,80)) . set order=order+1 . set DispWords=$order(@pArray@(DispWords)) if $get(Header)'="" set @ref@("HD")=Header ;"Note: Rules of use: ;" ref must=^TMP("VEE",$J) ;" Each line should be in this format: ;" @ref@(number)=ReturnValue_$char(9)_DisplayValue ;" @ref@(number)=ReturnValue_$char(9)_DisplayValue ;" @ref@(number)=ReturnValue_$char(9)_DisplayValue ;" Results come bac in: ;" ^TMP("VPE","SELECT",$J) D SELECT^%ZVEMKT(ref)
;"Format selected options. new index set index=$order(^TMP("VPE","SELECT",$J,"")) if index'="" for do quit:(index="") . new s,s1,s2 . set s=$get(^TMP("VPE","SELECT",$J,index)) . set s1=$piece(s,$char(9),1) . set s2=$piece(s,$char(9),2) . set @pResults@(s2)=s1 . set index=$order(^TMP("VPE","SELECT",$J,index)) kill ^TMP("VPE","SELECT",$J) kill @ref SelDone quit
TestSel new temp,results set temp("Kevin")="option 1" set temp("John")=123345 set temp("Bill")=$J do Selector("temp","results","Here is some header text") if $data(results) zwr results(*) quit