1
! @(#)dscedit.prg 19.1 (ESO-DMD) 02/25/03 13:20:09
2
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
! MIDAS procedure dscedit.prg to provide editing of descriptors
5
! of images or tables, e.g. the descriptor HISTORY
6
! K. Banse 870303, 900703, 921021, 931103, 940131, 980121, 021217
8
! use as @a dscedit name descr [dsctype] [clean_flag]
9
! where name = name of image frame
10
! for tables you must enter `name.tbl'
11
! descr = name of descriptor which you want to edit
12
! dsctype = type of descr., only needed if new descr.
13
! clean_flag = Y(es) or N(o), if you want to clean up the descriptors
16
! the editor will be the one defined via the SET/MIDAS_SYSTEM EDITOR=...
19
! note, that numerical data has to be separated by a blank, NOT by a comma...
21
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23
define/param p1 ? ima "Enter file name:"
24
define/param p2 ? c "Enter name of descr:"
25
define/param p3 c c "Enter type of new descr:"
26
define/param p4 n c "Enter clean_flag: "
29
define/local filnam/c/1/60 {p1}
31
! get contents of descriptor into file middummz.txt
32
read/descr {filnam} {p2} H >middummz.txt
33
define/local dexi/i/1/1 {outputi(1)}
34
define/local dtype/c/1/1 d
36
write/keyw dtype/c/1/1 {p3(1:1)}
38
if outputi(2) .eq. 1 then
39
write/keyw dtype/c/1/1 i
40
elseif outputi(2) .eq. 2 then
41
write/keyw dtype/c/1/1 r
42
elseif outputi(2) .eq. 3 then
43
write/keyw dtype/c/1/1 c
46
! edit that file with a normal text editor
47
if mid$sys(21:21) .eq. "$" then
48
{mid$sys(21:30)} middummz.txt
50
$ {mid$sys(21:30)} middummz.txt
53
! now delete the descriptor (if it exists)
54
if dexi .eq. 1 delete/descr {filnam} {p2}
56
! and store contents of edited file back into descriptor
57
assign/in file middummz.txt
58
write/descr {filnam} {p2}/{dtype}/1/30 !the 30 will be overwritten...
61
! finally reclaim the space lost due to the DELETE/DESCR command above
62
if p4(1:1) .eq. "Y" .and. dexi .eq. 1 then
63
define/local tb/i/1/1 0
64
tb = m$index(filnam,".tbl")
66
copy/ii {filnam} &x ? d,no !no update of HISTORY descr.
67
rename/image &x {filnam} NO
69
copy/table {filnam} middummx
70
rename/table middummx {filnam} NO