;+ ; NAME: ; NEWPROC ; ; PURPOSE: ; Creating of new procedure. Checks first if a procedure with the ; same name already exists. If not the template.pro with the default ; header will be loaded into the editor set by the environment ; variable IMEDITOR (default is vi, if variable is not set). ; ; CATEGORY: ; Help ; ; ; CALLING SEQUENCE: ; newproc, 'procname' ; ; ; INPUTS: ; procname name of procedure to create ; ; ; OUTPUTS: ; New procedure ; ; RESTRICTIONS: ; ; ; EXAMPLE: ; newproc, 'create_table' ; ; SEE ALSO: ; getpro ; ; MODIFICATION HISTORY: ; Written by: Thomas.Oettli@sma.ch, 21-Dec-1992 ; 16-May-1994, added current directory to ; search path. ; ;- PRO newproc, proc i=0 found = -1 editor = getenv("IMEDITOR") cd, CURRENT=here path = str_sep(!PATH+':'+here,':') if strpos(proc,'.') EQ -1 then proc = proc + ".pro" WHILE i LE n_elements(path)-1 AND found EQ -1 DO BEGIN cd, path(i) OPENR, 99, proc, ERROR = err CLOSE, 99 IF (err EQ 0) THEN BEGIN found=1 ENDIF i=i+1 ENDWHILE if found EQ 1 then begin print, "Procedure with the same name already exists in ", path(i-1) print, "Please choose another name" print, " " endif else begin cd, here spawn, ['cp',!DIR+'/lib/idlmeteo/pro/template.pro',proc], /NOSHELL if strlen(editor) NE 0 then spawn, [editor,proc], /NOSHELL $ else spawn, ['vi',proc], /NOSHELL endelse END