1MED(1NCARG)                      NCAR GRAPHICS                     MED(1NCARG)
2
3
4

NAME

6       med - NCAR CGM metafile frame editor
7

SYNOPSIS

9       med  [  -e  command ]* [ -f sfilename ] [ -l local_dir ] [ -V ] [ file‐
10       name]
11

DESCRIPTION

13       med is a frame-level, metafile editor designed  to  resemble  syntacti‐
14       cally  UNIX's  sed(1)  and  ed(1).  med operates on a copy of filename,
15       called  a  buffer,  and overwrites a file only when  you  issue  the  w
16       (write)  command.   med provides line oriented editing commands to dis‐
17       play or delete frames from the buffer, to move, copy  or  merge  frames
18       within  the  buffer,  or  to write frames from and read frames into the
19       buffer. By default med reads in commands from standard input.
20

OPTIONS

22       -e command
23              command is a single med command. The valid med commands are dis‐
24              cussed  in  the Commands section below.  Multiple -e options may
25              appear on a single command line. Be careful  to  use  quotes  if
26              your  command  contains  spaces  or metacharacters that might be
27              interpreted by the shell. When this option is used med does  not
28              enter  interactive  mode.  It simply performs the given commands
29              and then exits.
30
31       -f sfilename
32              Execute the med line-separated list  of  commands  in  the  file
33              sfilename.  After the commands are exhausted med will exit.
34
35       -l local_dir
36              Use  local_dir  as  the tmp directory for scratch disk space. If
37              this option is not specified med  will  use  the  value  of  the
38              $NCARG_TMP  or  the  $TMPDIR  environment variable. See ncargin‐
39              tro(1ncarg) for a discussion on NCAR Graphics environment  vari‐
40              ables.
41
42       -V     Print the version number and then exit.
43

USAGE

45   Command Structure
46       med commands attempt to have a syntactically identical form to those of
47       ed(1) or sed(1).  Commands  consist  of  an  optional  address  or  two
48       optional,  comma separated, addresses, followed by a command, which may
49       be abbreviated, possibly followed by a third address or a command  spe‐
50       cific argument list :
51
52              [ address [, address ] ] command [ address | args ]
53
54If  only one address is specified, operations are performed on that frame.  If
55two addresses are specified, med performs the operation on the inclusive range
56of  frames.   If  no  address is specified then the current frame is used as a
57default. The exception to this are the w (write) and the a (append)  commands.
58The default address for w is the entire buffer.
59
60For example, 1,10p means “print (display) frame 1 through 10” (two addresses),

d means “delete the current frame” (no address implies the current frame used

62as  default), and 1,5c5 means “append a copy of frames 1 through 5 at frame 5”
63(three addresses).  The meaning of argument  varies  for  each  operation.  In

med's current state the only valid argument is a filename — for the write, w ,

65command for instance, argument is the name of the file to write to.
66
67Unlike its friends ed(1) and sed(1) med attempts to be fairly  user  friendly.
68If  an  invalid  or  ambiguous  command  is given med will tell you so. If med
69thinks it recognizes a command with invalid arguments a  usage  statement  for
70the offending command is given. If a particular command fails and med is smart
71enough to figure out why it will tell you.  med will almost ALWAYS immediately
72terminate  when  an  error occurs while processing commands from a file or the
73command line. Help is available by using the h command. Usage statements for a
74particular command may be obtained with: h command name .
75
76   Addresses
77       Frames can be addressed in several ways:
78
79       nnn    By  frame number.  Frames in the buffer are numbered relative to
80              the start of the buffer.  The first frame is frame 1.
81
82       $      The last frame of the buffer.
83
84       .      The current frame.  med keeps track of the frame  on  which  you
85              last  performed  an operation.  This frame is called the current
86              frame.  You can address this frame by typing a “dot” character.
87
88       ±n     By relative frame number.  Address the frame number  that  is  n
89              frames higher, or n frames lower than the current frame.
90
91       address±n
92              An address followed by a plus sign (+) or a minus sign (-), fol‐
93              lowed by a decimal number, specifies that address plus or  minus
94              the  indicated number of frames.  If the address is omitted, the
95              current  frame  is  used  as  the  base.   For  example,  `31-3'
96              addresses frame 28 in the buffer.
97
98       If you do not specify an address for a command to operate on, a command
99       that requires an address supplies one by default, usually  the  current
100       frame.
101
102       A  pair  of addresses separated by a comma signifies an inclusive range
103       of frames, and the current frame is  not  changed  unless  the  command
104       changes it.
105
106   Commands
107       Only one command may appear per line.  Commands may accept zero, one or
108       two addresses, followed by possibly a third  address  or  an  argument.
109       Commands  that  accept  up to two addresses regard a third as an error.
110       Likewise, commands that do not accept an  argument  regard  one  as  an
111       error. Commands may be abbreviated.
112
113       In  the  absence of a second address for a two or three address command
114       the command will regard the second address as the same  as  the  first.
115       For  example,  2d  is  equivalent  to  2,2d  .   The absence of a first
116       address, where required, will result in the current frame being used as
117       the  default.  The  same  is  true  in  the absence of a required third
118       address. For example, c is equivalent to .,.c..
119
120       The commands q (quit) and e (edit) may be followed by a '!' to override
121       med's user protection.
122
123       In  the following list of med commands, the default addresses/arguments
124       appear in parentheses; the parenthesized addresses are not part of  the
125       command.  Unless  otherwise noted a command does not change the current
126       frame number.
127
128       (1,$)append metafile
129              Append buffer to a file. Append the addressed frames in the buf‐
130              fer  to  metafile.  If no address is specified the entire buffer
131              is written. If the file does not exist create it.
132       (.,.) copy (.)
133              Copy frames. Duplicate the addressed frames in  the  buffer  and
134              append  them  after the third address. The current frame becomes
135              the destination of the last frame copied.
136       (.,.)delete
137              Delete the addressed lines from the buffer.  delete accepts  one
138              or two addresses; the default is the current frame.  The current
139              frame is set to the first frame after the deleted frame(s).
140       edit metafile
141              Edit a metafile.  The current contents of the  buffer,  if  any,
142              are  erased.  The  named  metafile is read in to the buffer. The
143              resulting current frame is the last  frame  in  the  buffer.  If
144              changes  have  been  made to the buffer since the last write med
145              will refuse the request unless the command is  appended  with  a
146              '!'.   edit  prints  the number of frames in the metafile. If no
147              metafile is given, the current metafile, if any  is  used.   The
148              current frame becomes the last frame in the file.
149       help command
150              help.  Give  a  usage  message  for  command .  If no command is
151              given, print list of command names with a short  description  of
152              each.
153       (.,.)label string
154              Label  the addressed frames with string .  The CGM Begin Picture
155              element contained in each metafile frame allows for the encoding
156              of  character  data.   label provides a means for accessing this
157              data.
158       (.,.)merge
159              Merge the contents of the second addressed frame on top  of  the
160              first  addressed  frame.  The  first  addressed  frame  is  thus
161              changed. The second frame remains the same. The current frame is
162              set to the first addressed frame.
163       (.,.) move (.)
164              Move the addressed frames to the first frame following the third
165              address.
166       (.,.)print
167              Show the contents of the buffer at the given  address.  What  is
168              actually   displayed  is  information  regarding  the  addressed
169              frames. This information includes: relative frame number  within
170              the  buffer,  the  number of records contained in the frame, the
171              starting record for the frame and the contents of the  CGM  ele‐
172              ment  BEGIN  PICTURE  .   If no address is specified the current
173              frame does not change.  Otherwise  it  becomes  the  last  frame
174              printed.
175       quit
176              Quit.  Terminate  the  editing session without saving the buffer
177              contents. In order to save the buffer an explicit write must  be
178              performed.  If  changes  to  the buffer have been made since the
179              last write med will refuse to terminate unless quit is  appended
180              with a '!'.
181       (.)read metafile
182              Read  in a metafile. Read the contents of metafile into the buf‐
183              fer and append it at the given  address.   metafile  must  be  a
184              valid  NCAR  CGM.  The resulting current frame is the last frame
185              read in.
186       (1,$)split<number> outfile
187              Split the current metafile into number files. The split  command
188              attempts  to  create number metafiles from the addressed frames,
189              each containing approximately n / number frames where 'n' is the
190              total  number  of addressed frames. The first file is named out‐
191              file001.ncgm, the second file is named outfile002.ncgm,  and  so
192              on lexicographically. If no outfile is given, med is used as the
193              default (output files will be called  med001.ncgm,  med002.ncgm,
194              etc.).
195       (1,$)write metafile
196              Write  buffer.  Write  the  addressed  frames  in  the buffer to
197              metafile.  If no address is specified the entire buffer is writ‐
198              ten.  If  the  file does not exist create it. If no file name is
199              specified med uses the last currently remembered file  name,  if
200              any.  The  currently  remembered file name is the file name from
201              the most recent edit command, or the file name med  was  invoked
202              with if no edit commands have been issued.
203       ! command
204              Escape  to  the  shell  and execute command.  command is a valid
205              UNIX command.

ENVIRONMENT

207       NCARG_TMP
208              If set, this environment variable contains a directory  path  to
209              be  used  for  temporary  files.  On most systems the default is
210              /tmp.

FILES

212       /tmp/cgm_tools.#    temporary; # is the process id.
213

EXAMPLES

215       To concatenate the files ncgm1, ncgm2, and ncgm3  into  a  single  file
216       ncgm123 one might use the following:
217
218              % med -e 'r ncgm1' -e 'r ncgm2' -e 'r ncgm3' -e 'w ncgm123'
219
220       Or  one could pass the following script to med as a -fscriptfile option
221       or enter the commands interactively.
222
223              r ncgm1
224              r ncgm2
225              r ncgm3
226              w ncgm123
227
228       To Overlay the contents of frame 5 on top of frame 4 from a file  ncgm1
229       one could execute:
230              % med -e '4,5 me' -e 'w!' ncgm1
231

SEE ALSO

233       cgm(5NCARG), ed(1), sed(1V)
234
235       Hardcopy: NCAR Graphics Fundamentals, UNIX Version

BUGS

237       med
238        does not understand filenames that begin with a digit or a period.
239

CAVEATS

241       The  append,  read and merge commands may produce surprising results. A
242       CGM may contain a set of global graphical primitive attributes that are
243       applied  to  every frame in a file.  Thus reading frames in from a file
244       with different global attributes than the current working file may  not
245       produce the desired effect. The same is true when appending frames to a
246       previously existing file.  Similarly, the CGM standard  specifies  that
247       graphical  attributes specified within a metafile frame affect all suc‐
248       ceeding primitives. Thus a frame which is the product of the merge com‐
249       mand may appear differently than expected.
251       Copyright (C) 1987-2009
252       University Corporation for Atmospheric Research
253
254       The use of this Software is governed by a License Agreement.
255
256
257
258NCARG                            January 1993                      MED(1NCARG)
Impressum