;+ ; ; @file_comments ; ; @categories ; ; @param WIDCMD ; ; @param TOREAD ; ; @param NUMBEROFREAD ; ; @param PREFIX ; ; @param NAMEEXP ; ; @param ENDING ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ; ; @todo ; seb ; ;- PRO cutcmd, widcmd, toread, numberofread, prefix, nameexp, ending ; compile_opt idl2, strictarrsubs ; dummy = where(byte(widcmd) EQ (byte('"'))[0], nbdblquote) CASE 1 OF nbdblquote MOD 2: stop ; odd numbers are impossibles... nbdblquote GT 0: nbdblquote EQ 0:BEGIN ; widcmd is an expression of type: ; numb1*a + numb2*b ... + numb ; we will change into the form ; numb1*"a" + numb2*"b" ... + numb ; in order to suits the new method of cutcmd widcmd = strtrim(widcmd, 2) ; we force to start with a + or - case 1 of strpos(widcmd, '+') EQ 0: strpos(widcmd, '-') EQ 0: ELSE:widcmd = '+' + widcmd ENDCASE separator = strsplit(widcmd, '[^-/*+]', /extract, /regex) other = strsplit(widcmd, '+-*/', /extract) IF n_elements(separator) NE n_elements(other) THEN stop widcmd = '' FOR i = 0, n_elements(other)-1 DO BEGIN IF isnumber(other[i]) LT 1 THEN other[i] = '"' + other[i] + '"' widcmd = widcmd + separator[i] + other[i] ENDFOR ; print, widcmd END ENDCASE cutted = strsplit(widcmd, '"', /extract) IF strpos(widcmd, '"') EQ 0 THEN start = 0 ELSE start = 1 nameexp = cutted[start:*:2] numberofread = n_elements(nameexp) IF toread GE numberofread then begin dummy = report('toread cannot be larger than numberofread') stop ENDIF IF n_elements(cutted) EQ 1 THEN other = '' ELSE other = cutted[1-start:*:2] ; make sure that we have a prefix for each nameexp IF start EQ 0 THEN other = ['', other] ; nameexp = nameexp[toread] prefix = other[toread] IF n_elements(other) EQ numberofread + 1 THEN ending = other[numberofread] ELSE ending = '' ; ;help, prefix, nameexp, ending ; return end