' Name: SEd_LoadAllScripts
'
' Title: Load and name scripts (Montgomery T)
'
' Author: Tara Montgomery 10/09/99
'
' Description: Loads selected scripts from a directory in the current project and
'              names them the same as the file name
'
' Topics: Utility, Scripts, Load
'
' Search Keys: Script, SEd, Scripts - saving
'
' Requires:
'
' Self:
'
' Returns:
'

theProject = av.GetProject
theFileLabels = {"Avenue","Text","All Files"}
theFilePatterns = {"*.ave","*.txt","*.*"}
theDirList = FileDialog.ReturnFiles(theFilePatterns,theFileLabels,"Select script file(s)",0)
theLineList = List.Make
if (theDirList.Count=0) then
  return Nil
  msgbox.ERROR("Please select file(s).","ERROR - File Selection")
elseif ((theDirList.Count=1) or (theDirList.Count>1)) then
  for each theFileName in theDirList
    theBaseName = theFileName.GetBaseName
    theSed = SEd.Make
    theSed.SetName(theBaseName)
    theTextFile = TextFile.Make(theBaseName.AsFileName,#FILE_PERM_READ)
    theSource = theTextFile.Read(theTextFile.GetSize)
    theSed.SetSource(theSource)
    theTextFile.Close
    theSed.Compile
  end
end