source: cprs/branches/tmg-cprs/m_files/TMGBUTIL.m@ 861

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

Initial upload

File size: 4.1 KB
RevLine 
[796]1TMGBUTIL ;TMG/kst/Binary Global Data Utilities ;03/25/06
2 ;;1.0;TMG-LIB;**1**;08/20/05
3
4 ;"TMG BINARY GLOBAL DATA UTILITY FUNCTIONS
5 ;"Kevin Toppenberg MD
6 ;"GNU General Public License (GPL) applies
7 ;"8-20-2005
8
9 ;"=======================================================================
10 ;" API -- Public Functions.
11 ;"=======================================================================
12 ;"DISPLAY(globalRef,incSubscr,offset,numLines,bytesPerLine)
13 ;"BROWSE(globalRef,incSubscr)
14
15 ;"=======================================================================
16 ;"PRIVATE API FUNCTIONS
17 ;"=======================================================================
18
19
20 ;"=======================================================================
21 ;"DEPENDENCIES
22 ;"=======================================================================
23 ;"Uses: TMGBINF
24 ;" TMGMISC
25 ;" TMGSTUTL
26
27 ;"=======================================================================
28
29BROWSE(globalRef,incSubscr)
30 ;"SCOPE: PUBLIC
31 ;"Purpose: to browse a binary set as hex codes
32
33 new offset set offset=0
34 new input
35 for do quit:(offset="")
36 . read "Offset to browse (? for help): ",input:$get(DTIME,3600),!
37 . if input="?" write "^ to abort,A=browse up, Z=browse down",! quit
38 . if input="^" set offset="" quit
39 . if input="" set input="Z"
40 . if "Aa"[input set offset=offset-(8*16)
41 . if "Zz"[input set offset=offset+(8*16)
42 . if $extract(input,1)="$" set input=$$HEX2NUM^TMGMISC(input)
43 . if +input=input set offset=input
44 . if +offset'=offset set offset="" quit
45 . do DISPLAY(globalRef,incSubscr,offset,8,16)
46
47 quit
48
49
50DISPLAY(globalRef,incSubscr,offset,numLines,bytesPerLine)
51 ;"SCOPE: PUBLIC
52 ;"Purpose: to display a binary set as hex codes
53 ;"Input: gobalRef -- the reference of the beginning of the block (in closed form)
54 ;" incSubscr-- (required) Identifies the incrementing subscript level. For example, if you
55 ;" pass ^TMP(115,1,1,0) as the global_ref parameter and pass 3 as the
56 ;" inc_subscr parameter, $$BIN2GBL will increment the third subscript, such
57 ;" as ^TMP(115,1,x), but will WRITE notes at the full global reference, such
58 ;" as ^TMP(115,1,x,0).
59 ;" offset -- (OPTIONAL) the bytes offset from the beginning of the
60 ;" block to start from. Default=0
61 ;" numLines -- (OPTIONAL) the number of lines to show. Default=8
62 ;" bytesPerLine -- (OPTIONAL) the number of bytes to show per line Default=16
63 ;"Output -- displays the hex bytes to the screen
64 ;"Result -- none
65
66 ;"Note: each line in the global ref is assumed to hold 512 bytes.
67
68 new index,data
69 new bytesNeeded
70 new atEnd set atEnd=0
71
72 set offset=$get(offset,0)
73 set numLines=$get(numLines,8)
74 set bytesPerLine=$get(bytesPerLine,16)
75 set bytesNeeded=numLines*bytesPerLine
76 set index=offset\512
77
78 if index>0 set globalRef=$$NEXTNODE^TMGBINF(globalRef,incSubscr,1,index)
79 if (globalRef="") goto DispDone
80 set data=$extract($get(@globalRef),(offset#512)+1,512)
81
82 for quit:($length(data)'<bytesNeeded)!(atEnd>0) do
83 . set globalRef=$$NEXTNODE^TMGBINF(globalRef,incSubscr,1,1)
84 . if (globalRef="") set atEnd=1 quit
85 . new oneLine set oneLine=$get(@globalRef)
86 . if oneLine="" set atEnd=1 quit
87 . set data=data_$extract(oneLine,1,bytesNeeded-$length(data))
88
89 ;"Now display data
90 new dispLine
91 new dispOffset set dispOffset=offset
92 for quit:($length(data)=0) do
93 . set dispLine=$extract(data,1,bytesPerLine)
94 . set data=$extract(data,bytesPerLine+1,bytesNeeded)
95 . write "$",$$HEXCHR2^TMGMISC(dispOffset,6)," "
96 . write $$STRB2H^TMGSTUTL(dispLine,1),!
97 . set dispOffset=dispOffset+bytesPerLine
98
99
100DispDone
101 quit
Note: See TracBrowser for help on using the repository browser.