source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/cutcmd.pro @ 114

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1PRO cutcmd, widcmd, toread, numberofread, prefix, nameexp, ending
2;
3;
4  compile_opt idl2, strictarrsubs
5;
6  dummy = where(byte(widcmd) EQ (byte('"'))[0], nbdblquote)
7  CASE 1 OF
8    nbdblquote MOD 2: stop ; odd numbers are impossibles...
9    nbdblquote GT 0:
10    nbdblquote EQ 0:BEGIN
11; widcmd is an expression of type:
12; numb1*a + numb2*b ... + numb
13; we will change into the form
14; numb1*"a" + numb2*"b" ... + numb
15; in order to suits the new method of cutcmd
16      widcmd = strtrim(widcmd, 2)
17; we force to start with a + or -
18      case 1 of
19        strpos(widcmd, '+') EQ 0:
20        strpos(widcmd, '-') EQ 0:
21        ELSE:widcmd = '+' + widcmd
22      ENDCASE
23      separator = strsplit(widcmd, '[^-/*+]', /extract, /regex)
24      other = strsplit(widcmd, '+-*/', /extract)
25      IF n_elements(separator) NE n_elements(other) THEN stop
26      widcmd = ''
27      FOR i = 0, n_elements(other)-1 DO BEGIN
28        IF isnumber(other[i]) LT 1 THEN other[i] = '"' + other[i] + '"'
29        widcmd = widcmd + separator[i] + other[i]
30      ENDFOR
31;      print, widcmd
32    END
33  ENDCASE
34
35  cutted = strsplit(widcmd, '"', /extract)
36  IF strpos(widcmd, '"') EQ 0 THEN start = 0 ELSE start = 1
37  nameexp = cutted[start:*:2]
38  numberofread = n_elements(nameexp)
39  IF toread GE numberofread then begin
40    dummy = report('toread cannot be larger than numberofread')
41    stop
42  ENDIF
43  other = cutted[1-start:*:2]
44; make sure that we have a prefix for each nameexp
45  IF start EQ 0 THEN other = ['', other]
46;
47  nameexp = nameexp[toread]
48  prefix = other[toread]
49  IF n_elements(other) EQ numberofread + 1 THEN ending = other[numberofread] ELSE ending = ''
50;
51;help, prefix, nameexp, ending
52;
53  return
54end
Note: See TracBrowser for help on using the repository browser.