source: trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/cutcmd.pro @ 69

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

debug + new xxx

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