source: trunk/SRC/Utilities/createpro.pro @ 97

Last change on this file since 97 was 97, checked in by pinsard, 18 years ago

start to modify headers of Obsolete *.pro files for better idldoc output

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; @file_comments write an idl procedure, compile it and execute it.
6;
7; @param command {in}{required} a string array defining the procedure to be created. each element will be a line of the created procedure.
8;
9; @keyword FILENAMEIN name of the procedure to be created.
10;      'for_createpro.pro' by default
11;
12; @keyword KWDLIST a vector string. to specify a list of keywords that
13;      must be included in the procedure definition. Warning: the string
14;      must start with a ',' for example: KWDLIST = ', TOTO = toto'
15;
16; @keyword _EXTRA used to pass your keywords to the created procedure.
17;
18; SIDE EFFECTS: ends the procedure name with '.pro' if needed
19;
20; @restrictions is not working with functions, use createfunc instead.
21;              arguments can be given only through keywords
22;
23; @examples
24;      IDL> createpro, ['print,''OK'''], filename='test'
25;      IDL> createpro, ['if keyword_set(ok) then print,''OK'' else print, ''No'''] $
26;      IDL>   , filename = 'test', kwdlist =', ok = ok'
27;      IDL> createpro, ['if keyword_set(ok) then print,''OK'' else print, ''No'''] $
28;      IDL>   , filename = 'test', kwdlist = ', ok = ok', /ok
29;
30;
31; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
32; cleaning + new keywords: October 2005
33; Feb. 2006: supress keyword "kwdused" and use call_procedure instead of execute
34;-
35;------------------------------------------------------------
36;------------------------------------------------------------
37;------------------------------------------------------------
38PRO createpro, command, FILENAMEIN = filenamein $
39               , KWDLIST = kwdlist, KWDUSED = kwdused, _extra = ex
40;
41  compile_opt idl2, hidden, strictarrsubs
42;
43  IF keyword_set(kwdused) THEN BEGIN
44    dummy = report(['keyword KWDUSED has been suppressed,' $
45                    , 'please pass directly your keywords through _extra,' $
46                    , 'see exaemples in createpro header'])
47    return
48  ENDIF
49; define filename if needed
50  if NOT keyword_set(filenamein) then filename = 'for_createpro.pro' $
51  ELSE filename = filenamein
52; get the name of the procedure (not the name of the file containing the procedure)
53   shortfilename =  file_basename(filename, '.pro')
54; check if the directory exists
55   dirname = isadirectory(file_dirname(filename) $
56                          , title = 'Redefine '+shortfilename+'.pro directory')
57   IF size(dirname, /type) NE 7 THEN return
58;
59   filename = dirname + shortfilename + '.pro'
60; create the file
61   if NOT keyword_set(kwdlist) then kwdlist = ''
62   kwdlist = kwdlist + ', _extra = ex'
63   kwdlist = strtrim(kwdlist, 2)
64   IF strmid(kwdlist, 0, 1) NE ',' THEN kwdlist = ', ' +  kwdlist
65;  for i = 0, n_elements(command)-1 do print, command[i]
66   putfile, filename, ['pro ' + shortfilename + kwdlist $
67                       , 'compile_opt idl2, hidden, strictarrsubs', command, 'return', 'end']
68; go in dirname directory
69   cd, dirname, current = old_dir
70; compile it
71   resolve_routine, shortfilename
72   cd, old_dir
73; execute it
74   call_procedure, shortfilename, _extra = ex
75;
76   return
77end
Note: See TracBrowser for help on using the repository browser.