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

Last change on this file since 74 was 74, checked in by smasson, 18 years ago

debug xxx and cie + clean data file + rm perldoc_idl

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