source: cprs/branches/tmg-cprs/m_files/TMGBROWS.m@ 1713

Last change on this file since 1713 was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 3.7 KB
Line 
1TMGBROWS ;TMG/kst/Record browser ;03/25/06
2 ;;1.0;TMG-LIB;**1**;03/10/07
3
4 ;" TMG BROWSE RECORDS
5 ;"Kevin Toppenberg MD
6 ;"GNU General Public License (GPL) applies
7 ;"3-10-2007
8
9 ;"=======================================================================
10 ;" API -- Public Functions.
11 ;"=======================================================================
12 ;"ASKBROWSE -- browse records, and follow pointers
13
14 ;"=======================================================================
15 ;" Private Functions.
16 ;"=======================================================================
17 ;"Browse(FileNum,IENS,ShowEmpty) --Browse a record, allowing display of
18 ;" the current record, or follow pointers to other records.
19 ;"DispRec(FileNum,IEN) -- To display record
20
21 ;"=======================================================================
22
23
24ASKBROWSE
25 ;"Purpose: To browse records, and follow pointers.
26
27 write !!," -= RECORD BROWSE =-",!
28 new FIENS,IENS
29AL1
30 set FIENS=$$AskFIENS^TMGDBAPI()
31 if (FIENS["?")!(FIENS="^") goto ASKDone
32
33 set FileNum=$piece(FIENS,"^",1)
34 set IENS=$piece(FIENS,"^",2)
35
36AL2
37 set IENS=$$AskIENS^TMGDBAPI(FileNum,IENS)
38 if (IENS["?")!(IENS="") goto AL1
39
40 new % set %=2
41 write "Display empty fields"
42 do YN^DICN
43 if %=-1 write ! goto ASKDone
44
45 ;"Do the output
46 write ! do Browse(FileNum,IENS,(%=1))
47 set IENS=$piece(IENS,",",2,99) ;"force Pick of new record to dump
48 if +IENS>0 goto AL2
49 goto AL1
50
51
52ASKDone
53 quit
54
55
56Browse(FileNum,IENS,ShowEmpty)
57 ;"Purpose: Browse a record, allowing display of the current record, or
58 ;" follow pointers to other records.
59 ;"Input: FileNum -- the number of the file to browse
60 ;" IENS -- the record number to display (or IENS: #,#,#,)
61 ;" ShowEmpty -- OPTIONAL; if 1 then empty fields will be displayed
62
63 new FldInfo,field
64 do GetPtrsOUT^TMGDBAPI(FileNum,.FldInfo)
65
66 if $extract(IENS,$length(IENS))'="," set IENS=IENS_","
67
68 set field=""
69 for set field=$order(FldInfo(field)) quit:(field="") do
70 . new name set name=$$GetFldName^TMGDBAPI(FileNum,field)
71 . set FldInfo(field,"NAME")=name
72
73 new Menu
74 new count set count=1
75 write "File: ",$$GetFName^TMGDBAPI(FileNum),!
76
77 set Menu(0)="File: "_$$GetFName^TMGDBAPI(FileNum)_" ("_FileNum_"), Record: "_IENS
78 set field=""
79 for set field=$order(FldInfo(field)) quit:(field="") do
80 . new ptr set ptr=$$GET1^DIQ(FileNum,IENS,field,"I")
81 . new otherName set otherName=$$GET1^DIQ(FileNum,IENS,field)
82 . if ptr="" quit
83 . new name set name=$$GetFldName^TMGDBAPI(FileNum,field)
84 . set Menu(count)="BROWSE: ("_field_") "_name_"--> "_otherName_$char(9)_FldInfo(field)_"|"_ptr
85 . set count=count+1
86
87 set Menu(count)="DUMP entire record"_$char(9)_"DUMP"
88
89M0 write #
90 set UsrSlct=$$Menu^TMGUSRIF(.Menu,"^")
91
92 if UsrSlct="DUMP" do DispRec(FileNum,IENS) goto M0
93 if UsrSlct["|" do goto M0
94 . new newFile set newFile=$piece(UsrSlct,"|",1)
95 . new IEN set IEN=$piece(UsrSlct,"|",2)_","
96 . do Browse(newFile,IEN,.ShowEmpty)
97 if UsrSlct="^" goto MenuDone
98 goto M0
99
100MenuDone
101 quit
102
103
104DispRec(FileNum,IEN)
105 ;"Purpose: To display record
106 ;"Input: FileNum -- The File number to display
107 ;" IEN -- the IEN (record number) to display in file.
108 ;"Results: none
109
110 write "File: ",$$GetFName^TMGDBAPI(FileNum),!
111 do DumpRec2^TMGDEBUG(FileNum,IEN_",",0)
112 do PressToCont^TMGUSRIF
113
114 quit
115
Note: See TracBrowser for help on using the repository browser.