#|

Universal Load

Note: This is an example file showing concepts of the Integration Kit. The code itself is not supported and will never be supported.
|#


(in-package :EXAMPLES)
(use-package :OLI)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(sd-defdialog 'universal_load
  :dialog-title "Load"
  :variables
  '(
    (FILE :value-type :filename :direction :input
	  :prompt-text "Identify file or press Next")
    (NEXT :push-action (when file
			     (loadit)
			     (setf file nil)))
    )
  :local-functions
  '(
    (loadit ()
     (let*
      ((filename (first file))
       (ext (subseq filename (or (position #\. filename) 0))))
      (cond
       ((sd-string= ext ".lsp") (load filename))
       ((sd-string= ext ".rec") (load filename))
       ((sd-string= ext ".sda") (sd-call-cmds (load_sd filename)))
       ((sd-string= ext ".sdp") (sd-call-cmds (load_sd filename)))
       ((sd-string= ext ".sds") (sd-call-cmds (load_sd filename)))
       ((sd-string= ext ".sdw") (sd-call-cmds (load_sd filename)))
       ((sd-string= ext ".pkg") (sd-call-cmds (load_package filename)))
       ((sd-string= ext ".env") (load filename))
       ((sd-string= ext ".ses") (sd-call-cmds (load_session :yes filename)))
       ((sd-string= ext ".xmit") (sd-call-cmds (load_me30 filename)))
       ((sd-string= ext ".mi") (sd-call-cmds (load_profile filename)))
       (t (sd-display-error "Unknown file type")))))
    )
  :start-variable 'file
  :ok-action '(when file (loadit)))

;;