source: EWD/ewdapps/DIINQUIRE/r/C0EDIINQUIRE.m@ 1312

Last change on this file since 1312 was 1312, checked in by Sam Habiel, 12 years ago

DIINQUIRE, now functional, routine

File size: 3.1 KB
Line 
1C0EDIINQUIRE ; EWD Wrapper around Inquire into File Entries option
2 ;;
3 ; All EPs public
4 ;
5 ; TODO:
6 ; 1. Fileman controls file access based on very complex rules. Need to imp
7 ; 2. Lazy loading of entries
8 ; 3. Inquire needs to return structured data rather a blob--too hard right now.
9 ;
10FILES(sessid) ; Get File of Files
11 d clearList^%zewdAPI("file",sessid) ; Clean
12 N FILE S FILE="" ; Looper that is also the File Name
13 FOR S FILE=$O(^DIC("B",FILE)) QUIT:FILE="" DO ; ditto
14 . N IEN S IEN=$O(^(FILE,"")) ; IEN from 2nd subscript in B index
15 . d appendToList^%zewdAPI("file",FILE,IEN,sessid) ; Add to session
16 Q ""
17 ;
18ENTRY(file) ; Get first 20 Entries in a specific file
19 d clearList^%zewdAPI("entry",sessid) ; Clean
20 n glo s glo=^DIC(file,0,"GL") ; Get File Global
21 s glo=$$CREF^DILF(glo) ; Get the closed root reference
22 N ENTRY S ENTRY="" ; Looper that is also the Entry
23 N CNT S CNT=0
24 FOR S ENTRY=$O(@glo@("B",ENTRY)) QUIT:ENTRY="" QUIT:CNT>20 DO ; ditto
25 . N IEN S IEN=$O(^(ENTRY,"")) ; IEN
26 . d appendToList^%zewdAPI("entry",ENTRY,IEN,sessid) ; Add to session
27 . S CNT=CNT+1
28 QUIT $$replaceOptionsByID^%zewdAPI("entry","entry",sessid) ; Replace current options
29 ;
30INQ(sessid) ; DIINQUIRE Application Output
31 ;
32 ; First, get the options
33 n outopt ; Output Options checkbox values
34 d getCheckboxValues^%zewdAPI("outopt",.outopt,sessid)
35 n capopts s capopts="" ; Caption Options to get from checkbox values
36 n i s i=""
37 for set i=$order(outopt(i)) q:i="" s capopts=capopts_i
38 ;
39 ; Get File and Entry
40 n file s file=$$getSessionValue^%zewdAPI("file",sessid)
41 n entry s entry=$$getSessionValue^%zewdAPI("entry",sessid)
42 ;
43 ; Now actual VISTA work--write out the output to a file
44 ; Note that HFS uniqueness is guaranteed by the device file configuration
45 ; If you set IO=$$UNIQUE^%ZISUTL_$J in the pre-open execute, you are good.
46 S IOP="HFS" D ^%ZIS ; Open HFS Device
47 U IO ; USE HFS Device
48 D CAPTION^DIQ(file,entry,capopts) ; Write Out Report
49 D ^%ZISC ; Close Device
50 ; done
51 ;
52 ; This code doesn't work, and my debugger couldn't go through it.
53 ; something is wrong--and I have an old version of GT.M--why is this happening?
54 ; N PATH S PATH=$$PATH^MXMLPRSE(IO("CLOSE"))
55 ; N FILE S FILE=$P(IO("CLOSE"),PATH,2)
56 ; N RESULT S RESULT=$$FTG^%ZISH(PATH,FILE,$NAME(^TMP("EWDU",$J)),3) ; Doesn't work!!!
57 ;
58 ; ------------------> Read the File Back
59 OPEN IO("CLOSE"):(READONLY:rewind) ; Open Again for reading
60 USE IO("CLOSE") ; Use
61 N CNT S CNT=1 ; Counter
62 KILL ^TMP("EWDU",$J) ; Kill TMP Global
63 FOR DO Q:$ZEOF ; Read the file
64 . N % R %
65 . S ^TMP("EWDU",$J,CNT)=%
66 . S CNT=CNT+1
67 C IO("CLOSE"):(delete) ; Close and delete
68 ; <------------------ Close the File
69 ;
70 ; Move to EWD Session
71 d clearSessionArray^%zewdAPI("DIINQUIRE",sessid)
72 d mergeGlobalToSession^%zewdAPI($NAME(^TMP("EWDU",$J)),"DIINQUIRE",sessid)
73 QUIT ""
Note: See TracBrowser for help on using the repository browser.