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