' Name: SEd_SetName
'
' Title: Script namer (Montgomery T)
'
' Author: Tara Montgomery 10/15/1999
'
' Description: Sets the name of the SEd to the name in the first line of each
'              scripts (removes the 'Name: )
'
' Requires:   
'
' Self:
'
' Returns:

msgbox.Warning("CAUTION! This script will set the name of EVERY SEd in the project to the "+ "name listed in the first line of the script!","WARNING")

'Get all SEd's

theDocs = av.GetProject.GetDocs
theSEdlist = {}
for each theSEd in theDocs
  if (theSEd.is(SEd)) then
    theSEdlist.Add(theSEd)
  end
end
theCount = theSEdlist.Count.AsString

'Confirmation

theMsg = "There are "+theCount+" scripts. Do you want to set the Script name for all "+theCount+" scripts ?"
ok = MsgBox.YesNo(theMsg,"SET NAME CONFIRMATION",true)
if (ok.not) then
  return nil
end
for each theSEd in theSEdlist
  theSEd.GetWin.Open
  theSource = theSed.GetSource
  theSEd.GetWin.Close
  theStringList = theSource.AsList
  if (theStringList.Get(1).AsString.Trim="Name:") then
    theName = theStringList.Get(2).AsString.Trim
    theSEd.SetName(theName)
  elseif (theStringList.Get(1).AsString.Trim<>"Name: ") then
    theName = theStringList.Get(1).AsString.Trim
    msgbox.ERROR("The format of the name in the "+theSEd.GetName.AsSTring+" script appears to be incorrect."+NL+"The current string is "+theName+" ."+NL+NL+"Please edit the file then re-rerun.","ERROR - NAME FORMAT")
    return Nil
  end
end