source: trunk/procs/get_macro_def.pro @ 12

Last change on this file since 12 was 8, checked in by kolasinski, 17 years ago

Simplify macro_read.pro with get_macro_def - Add def_macro_base_fld.pro and get_macro_def.pro on the server - Bugfix for def_grid.pro also

File size: 1.2 KB
Line 
1;
2; Read macro definition
3;
4IF debug_w THEN print, '   ENTER get_macro_def...'
5
6; name of macro file
7   file_mac = hom_def+'fld_macros.def'
8   IF debug_w THEN print,  '    var_name in get_macro_def: ', var_name
9;
10; special case for stddev monthly
11   stddev_mth =  '00'
12   pos_underscore =  strpos(var_name,'_')
13   IF pos_underscore GE 0 THEN BEGIN
14      stddev_mth = STRMID(var_name, pos_underscore + 1, 2)
15      var_name = STRMID(var_name, 0, pos_underscore)
16   ENDIF
17
18; find definition of macro
19   spawn, 'grep -i " '+STRMID(var_name, 2, 16)+' " '+file_mac, line
20   line = strcompress(strtrim(line[0], 2))
21   length = strlen(line)
22   IF debug_w THEN print,  '    line: ', line
23
24   IF length EQ 0 THEN BEGIN
25      print, ' *** WARNING : No macro definition for field ', var_name, $
26       ' in file ', file_mac
27      stop
28   ENDIF
29
30
31; Separate macro def and legend+unit
32;
33   leg_pos = strpos(line,'<')
34   line_def = STRMID(line,0,leg_pos)
35   line_def = strcompress(strtrim(line_def[0], 2))
36   macro_def = str_sep(line_def, ' ')
37   nfields = n_elements(macro_def)
38;
39; extract legend and unit
40;
41   legend = extract_str(line, '<', '>')
42   unit = extract_str(line, '[', ']')
43
44IF debug_w THEN print, '   EXIT get_macro_def...'
Note: See TracBrowser for help on using the repository browser.