;+
;Procedure:  CWD  [,newdir]
;Purpose:    Change working directory
;Keywords:
;       /PICK   use dialog_pickfile to choose a directory
;       PROMPT = STRING   - Changes prompt to STRING+newdir
;                The value STRING is stored in a common block variable and
;                is not required in subsequent calls to CWD
;       PROMPT = 0    - Clear prompt string
;
;Other options:
;
;-
pro cwd,newdir,pick=pick,current=current,finaldir=finaldir,prompt=prompt
common cwd_com,prompt_root
if n_elements(prompt) ne 0 then prompt_root=prompt
if keyword_set(pick) then newdir = DIALOG_PICKFILE(/DIRECTORY)
if keyword_set(newdir) then cd,newdir,current=current
cd,current=finaldir
print,finaldir
if size(prompt_root,/type) eq 7 then  !prompt=prompt_root+finaldir+'> '
end