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
RevLine 
[2]1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
[97]5; @file_comments write an idl procedure, compile it and execute it.
[2]6;
[93]7; @param command {in}{required} a string array defining the procedure to be created. each element will be a line of the created procedure.
[2]8;
[93]9; @keyword FILENAMEIN name of the procedure to be created.
[11]10;      'for_createpro.pro' by default
[2]11;
[93]12; @keyword KWDLIST a vector string. to specify a list of keywords that
[11]13;      must be included in the procedure definition. Warning: the string
14;      must start with a ',' for example: KWDLIST = ', TOTO = toto'
[2]15;
[93]16; @keyword _EXTRA used to pass your keywords to the created procedure.
[2]17;
[74]18; SIDE EFFECTS: ends the procedure name with '.pro' if needed
[11]19;
[93]20; @restrictions is not working with functions, use createfunc instead.
[74]21;              arguments can be given only through keywords
[2]22;
[93]23; @examples
[11]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'''] $
[69]28;      IDL>   , filename = 'test', kwdlist = ', ok = ok', /ok
[2]29;
[11]30;
[93]31; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
[11]32; cleaning + new keywords: October 2005
[69]33; Feb. 2006: supress keyword "kwdused" and use call_procedure instead of execute
[2]34;-
35;------------------------------------------------------------
36;------------------------------------------------------------
37;------------------------------------------------------------
[11]38PRO createpro, command, FILENAMEIN = filenamein $
[69]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
[11]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 = ''
[69]62   kwdlist = kwdlist + ', _extra = ex'
[74]63   kwdlist = strtrim(kwdlist, 2)
64   IF strmid(kwdlist, 0, 1) NE ',' THEN kwdlist = ', ' +  kwdlist
[69]65;  for i = 0, n_elements(command)-1 do print, command[i]
[11]66   putfile, filename, ['pro ' + shortfilename + kwdlist $
[69]67                       , 'compile_opt idl2, hidden, strictarrsubs', command, 'return', 'end']
[11]68; go in dirname directory
69   cd, dirname, current = old_dir
70; compile it
[2]71   resolve_routine, shortfilename
[11]72   cd, old_dir
73; execute it
[69]74   call_procedure, shortfilename, _extra = ex
[11]75;
[2]76   return
77end
Note: See TracBrowser for help on using the repository browser.