~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to applic/proc/dscedit.prg

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
! @(#)dscedit.prg       19.1 (ESO-DMD) 02/25/03 13:20:09
 
2
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
3
!
 
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
 
7
!
 
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
 
14
!                       after the editing
 
15
 
16
! the editor will be the one defined via the SET/MIDAS_SYSTEM EDITOR=...
 
17
! command
 
18
 
19
! note, that numerical data has to be separated by a blank, NOT by a comma...
 
20
 
21
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
22
!
 
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: "
 
27
define/maxpar 4
 
28
!
 
29
define/local filnam/c/1/60 {p1}
 
30
 
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
 
35
if dexi .eq. 0 then
 
36
   write/keyw dtype/c/1/1 {p3(1:1)}
 
37
else
 
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
 
44
   endif
 
45
endif
 
46
!  edit that file with a normal text editor
 
47
if mid$sys(21:21) .eq. "$" then
 
48
   {mid$sys(21:30)} middummz.txt
 
49
else
 
50
   $ {mid$sys(21:30)} middummz.txt
 
51
endif
 
52
!
 
53
! now delete the descriptor (if it exists)
 
54
if dexi .eq. 1 delete/descr {filnam} {p2}
 
55
!
 
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...
 
59
assign/in terminal
 
60
!
 
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")
 
65
   if tb .lt. 2 then
 
66
      copy/ii {filnam} &x ? d,no                !no update of HISTORY descr.
 
67
      rename/image &x {filnam} NO
 
68
   else
 
69
      copy/table {filnam} middummx
 
70
      rename/table middummx {filnam} NO
 
71
   endif
 
72
endif