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

Last change on this file since 367 was 325, checked in by pinsard, 16 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1;+
2;
3; @file_comments
4;
5; @categories
6;
7; @param WIDCMD
8;
9; @param TOREAD
10;
11; @param NUMBEROFREAD
12;
13; @param PREFIX
14;
15; @param NAMEEXP
16;
17; @param ENDING
18;
19; @returns
20;
21; @uses
22;
23; @restrictions
24;
25; @examples
26;
27; @history
28;
29; @version
30; $Id$
31;
32; @todo
33; seb
34;
35;-
36PRO cutcmd, widcmd, toread, numberofread, prefix, nameexp, ending
37;
38  compile_opt idl2, strictarrsubs
39;
40  dummy = where(byte(widcmd) EQ (byte('"'))[0], nbdblquote)
41  CASE 1 OF
42    nbdblquote MOD 2: stop ; odd numbers are impossibles...
43    nbdblquote GT 0:
44    nbdblquote EQ 0:BEGIN
45; widcmd is an expression of type:
46; numb1*a + numb2*b ... + numb
47; we will change into the form
48; numb1*"a" + numb2*"b" ... + numb
49; in order to suits the new method of cutcmd
50      widcmd = strtrim(widcmd, 2)
51; we force to start with a + or -
52      case 1 of
53        strpos(widcmd, '+') EQ 0:
54        strpos(widcmd, '-') EQ 0:
55        ELSE:widcmd = '+' + widcmd
56      ENDCASE
57      separator = strsplit(widcmd, '[^-/*+]', /extract, /regex)
58      other = strsplit(widcmd, '+-*/', /extract)
59      IF n_elements(separator) NE n_elements(other) THEN stop
60      widcmd = ''
61      FOR i = 0, n_elements(other)-1 DO BEGIN
62        IF isnumber(other[i]) LT 1 THEN other[i] = '"' + other[i] + '"'
63        widcmd = widcmd + separator[i] + other[i]
64      ENDFOR
65;      print, widcmd
66    END
67  ENDCASE
68
69  cutted = strsplit(widcmd, '"', /extract)
70  IF strpos(widcmd, '"') EQ 0 THEN start = 0 ELSE start = 1
71  nameexp = cutted[start:*:2]
72  numberofread = n_elements(nameexp)
73  IF toread GE numberofread then begin
74    dummy = report('toread cannot be larger than numberofread')
75    stop
76  ENDIF
77  IF n_elements(cutted) EQ 1 THEN other = '' ELSE other = cutted[1-start:*:2]
78; make sure that we have a prefix for each nameexp
79  IF start EQ 0 THEN other = ['', other]
80;
81  nameexp = nameexp[toread]
82  prefix = other[toread]
83  IF n_elements(other) EQ numberofread + 1 THEN ending = other[numberofread] ELSE ending = ''
84;
85;help, prefix, nameexp, ending
86;
87  return
88end
Note: See TracBrowser for help on using the repository browser.