Changeset 74 for trunk/SRC/Utilities/createfunc.pro
- Timestamp:
- 05/23/06 15:45:47 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Utilities/createfunc.pro
r69 r74 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:create pro5 ; NAME:createfunc 6 6 ; 7 ; PURPOSE: write an idl procedure, compile it and execute it. 7 ; PURPOSE: write an idl function, compile it and execute it. 8 ; usefull to avoid the use of execute 8 9 ; 9 10 ; CATEGORY: 10 11 ; 11 ; CALLING SEQUENCE: createpro, command12 ; CALLING SEQUENCE:res = createfunc(command) 12 13 ; 13 14 ; INPUTS: 14 ; command: a s tring array defining the procedure to be created.15 ; each element will be a line of the created procedure.15 ; command: a scalar string defining the result to be byven back by the 16 ; function. (see examples) 16 17 ; 17 18 ; KEYWORD PARAMETERS: 18 19 ; 19 ; FILENAMEIN: name of the procedure to be created.20 ; 'for_create pro.pro' by default20 ; FILENAMEIN: name of the funccedure to be created. 21 ; 'for_createfunc.pro' by default 21 22 ; 22 23 ; KWDLIST: a vector string. to specify a list of keywords that 23 ; must be included in the proceduredefinition. Warning: the string24 ; must be included in the function definition. Warning: the string 24 25 ; must start with a ',' for example: KWDLIST = ', TOTO = toto' 25 26 ; 26 ; _EXTRA: used to pass your keywords to the created procedure.27 ; _EXTRA: used to pass your keywords to the created function. 27 28 ; 28 29 ; OUTPUTS: none … … 30 31 ; COMMON BLOCKS: none 31 32 ; 32 ; SIDE EFFECTS: ends t eh procedurename with '.pro' if needed33 ; SIDE EFFECTS: ends the function name with '.pro' if needed 33 34 ; 34 ; RESTRICTIONS: de marche pas pour les fonctions35 ; RESTRICTIONS:arguments can be given only through keywords 35 36 ; 36 37 ; EXAMPLE: 37 ; IDL> createpro, ['print,''OK'''], filename='test' 38 ; IDL> createpro, ['if keyword_set(ok) then print,''OK'' else print, ''No'''] $ 39 ; IDL> , filename = 'test', kwdlist =', ok = ok' 40 ; IDL> createpro, ['if keyword_set(ok) then print,''OK'' else print, ''No'''] $ 41 ; IDL> , filename = 'test', kwdlist = ', ok = ok', /ok 42 ; 38 ; IDL> print, createfunc('3*2', filename='test') 39 ; IDL> print, createfunc('3*two', filename = 'test' $ 40 ; , kwdlist ='two = two', two = 2) 43 41 ; 44 42 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 45 ; cleaning + new keywords: October 2005 46 ; Feb. 2006: supress keyword "kwdused" and use call_procedure instead of execute 43 ; May 2005 47 44 ;- 48 45 ;------------------------------------------------------------ … … 54 51 compile_opt idl2, hidden, strictarrsubs 55 52 ; 53 IF n_elements(command) NE 1 THEN stop 56 54 ; define filename if needed 57 55 if NOT keyword_set(filenamein) then filename = 'for_createfunc.pro' $ … … 68 66 if NOT keyword_set(kwdlist) then kwdlist = '' 69 67 kwdlist = kwdlist + ', _extra = ex' 68 IF strmid(kwdlist, 0, 1) NE ',' THEN kwdlist = ', ' + kwdlist 70 69 putfile, filename, ['function ' + shortfilename + kwdlist $ 71 70 , 'compile_opt idl2, hidden, strictarrsubs' $
Note: See TracChangeset
for help on using the changeset viewer.