source: trunk/procs/get_macro_def.pro

Last change on this file was 205, checked in by pinsard, 14 years ago

homegenize THEN BEGIN ... ENDIF

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1;+
2;
3; Read macro definition
4;
5; @todo
6; get rid of spawn
7;
8; should be a function
9;
10; @version
11; $Id$
12;
13;-
14   IF debug_w THEN BEGIN
15    info = report('enter ...')
16   ENDIF
17
18; name of macro file
19   file_mac = hom_def+'fld_macros.def'
20   IF debug_w THEN BEGIN
21    print, '    var_name in get_macro_def: ', var_name
22   ENDIF
23;
24; special case for stddev monthly
25   stddev_mth = '00'
26   pos_underscore = strpos(var_name,'_')
27   IF pos_underscore GE 0 THEN BEGIN
28      stddev_mth = STRMID(var_name, pos_underscore + 1, 6)
29      var_name = STRMID(var_name, 0, pos_underscore)
30   ENDIF
31
32; find definition of macro
33   spawn, 'grep -i " '+STRMID(var_name, 2, 16)+' " '+file_mac, line
34   line = strcompress(strtrim(line[0], 2))
35   length = strlen(line)
36   IF debug_w THEN BEGIN
37    print, '    line: ', line
38   ENDIF
39
40   IF length EQ 0 THEN BEGIN
41      print, ' *** WARNING : No macro definition for field ', var_name, $
42       ' in file ', file_mac
43      stop
44   ENDIF
45
46
47; Separate macro def and legend+unit
48;
49   leg_pos = strpos(line,'<')
50   line_def = STRMID(line,0,leg_pos)
51   line_def = strcompress(strtrim(line_def[0], 2))
52   macro_def = strsplit(line_def, ' ', /EXTRACT)
53   nfields = n_elements(macro_def)
54;
55; extract legend and unit
56;
57   legend = extract_str(line, '<', '>')
58   unit = extract_str(line, '[', ']')
59
60   IF debug_w THEN BEGIN
61    info = report('leaving ...')
62   ENDIF
Note: See TracBrowser for help on using the repository browser.