[69] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
[93] | 5 | ; test is a ".pro" file corresponds to an IDL procedure, |
---|
[69] | 6 | ; function or batch file. |
---|
| 7 | ; |
---|
[93] | 8 | ; @categories utilities |
---|
[69] | 9 | ; |
---|
[93] | 10 | ; @param file {in} A scalar of string type, the name of the ".pro" file to be tested |
---|
| 11 | ; if necessary, the input name is completed with '.pro' |
---|
[69] | 12 | ; and its path found in !path |
---|
| 13 | ; |
---|
[93] | 14 | ; @returns A scalar of string type: 'proc', 'func' or 'batch' |
---|
[69] | 15 | ; |
---|
[93] | 16 | ; @examples |
---|
[69] | 17 | ; |
---|
| 18 | ; IDL> print, protype('protype') |
---|
| 19 | ; func |
---|
| 20 | ; IDL> print, protype('protype.pro') |
---|
| 21 | ; func |
---|
| 22 | ; IDL> print, protype('init') |
---|
| 23 | ; batch |
---|
| 24 | ; IDL> print, protype('plt') |
---|
| 25 | ; proc |
---|
| 26 | ; |
---|
[93] | 27 | ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[69] | 28 | ; Feb 2006 |
---|
| 29 | ;- |
---|
| 30 | ;------------------------------------------------------------ |
---|
| 31 | ;------------------------------------------------------------ |
---|
| 32 | ;------------------------------------------------------------ |
---|
| 33 | FUNCTION protype, file |
---|
| 34 | ; |
---|
| 35 | filepro = (find(file[0], /onlypro, /firstfound))[0] |
---|
| 36 | if filepro EQ 'NOT FOUND' then return, -1 |
---|
| 37 | name = file_basename(filepro, '.pro') |
---|
| 38 | ; |
---|
| 39 | allines = getfile(filepro) |
---|
| 40 | CASE 1 OF |
---|
| 41 | ; this is a procedure |
---|
| 42 | max(stregex(allines, '^ *pro ?' + name, /fold_case, /boolean)):RETURN, 'proc' |
---|
| 43 | ; this is a function |
---|
| 44 | max(stregex(allines, '^ *function ?' + name, /fold_case, /boolean)):RETURN, 'func' |
---|
| 45 | ; this is an IDL batch file |
---|
| 46 | ELSE:RETURN, 'batch' |
---|
| 47 | ENDCASE |
---|
| 48 | |
---|
| 49 | RETURN, -1 |
---|
| 50 | END |
---|