'---------------------------------------------------------------- 'SCRIPT: avu-ScriptSaver 'PROJECT: gavos.apr, avcsus 'DATE: 02-16-96 'AUTHOR: John Ganter, Sandia National Labs, jganter@sandia.gov 'DESC: writes out Scripts to files 'DESC2: 'CALLED BY: avu-ScriptSaverCaller or other (see Dictionary below) 'CALL AS: av.Run("avu-ScriptSaver", dicParam) 'OBJ: dictionaryParam with two entries: 'ARG01: strDirSave: string name of save dir 'ARG02: listScripts: Script objects to save 'RETURNS: string 'EXPECTS: 'CALLS TO: ''''2---------------------------------------------------------------- ' Based on the ESRI SaveProjectScripts (savscrpt.ave), which can be ' found under Help/Examples on the Windows version ' ' > Description: Writes all scripts in the current project to the working ' > directory. The default filename will be the name of the SEd in the ' > project. Blanks in the name are substituted. The user may optionally ' > choose to enforce unique 8.3 compliant filenames. Otherwise, a warning ' > is displayed if the file already exists. ' ' Improvements: ' ' * Lets you choose scripts from the Project window ' * Preserves long script names when the OS supports them (Windows 95/NT, UNIX) ' ' If you are going to use something besides avu-ScriptSaverCaller, note this ' typical parameter dictionary: ' ' dicParam = Dictionary.Make(2) ' dicParam.Add("strDirSave", "c:\a") ' dicParam.Add("listScripts", listScripts) '---------------------------------------------------------------- saveDirStr = SELF.Get("strDirSave") 'MsgBox.Info(saveDirStr,"") 'saveDirStr = "c:\a\gavos\g1\aves" 'keep the old directory oldDir = av.GetProject.GetWorkDir av.GetProject.SetWorkDir(saveDirStr.AsFileName) saveDir = av.GetProject.GetWorkDir saveDirStr = av.GetProject.GetWorkDir.GetFullName ' If the scripts are to be saved elsewhere, change the following lines... 'saveDir = av.GetProject.GetWorkDir 'saveDirStr = av.GetProject.GetWorkDir.GetFullName if (File.Exists(saveDir).Not) then MsgBox.Error("Working directory:"++saveDirStr++"does not exist", "") exit end 'get the list of scripts from SELF (a Dictionary) and check it theScriptList = SELF.Get("listScripts") countScripts = theScriptList.Count if ( countScripts < 1) then MsgBox.Warning("No scripts in list","avu-ScriptSaver problem") exit end 'theScriptList = List.Make 'for each d in av.GetProject.GetDocs ' if (d.Is(SEd)) then ' theScriptList.Add(d) ' end 'end ok = MsgBox.YesNo("Are you sure you want to write" ++ countScripts.AsString ++ "script(s) to:"+NL+ saveDirStr+"?", "Save Scripts", true) if (ok.Not) then exit end 'do not make 8.3 names enforce = false ' Loop through write each script to a system file... ' 'enforce = MsgBox.YesNoCancel("Create 8.3 unique file names?", ' "Save Scripts", true) 'if (enforce = Nil) then ' exit 'end for each scriptName in theScriptList ' ' Substitute blanks and make lower case. ' Optionally use MakeTmp to enforce 8.3 compliance and uniqueness. ' theFile = scriptName.AsString.Substitute(" ","_") 'LCase removed 'theFile = scriptName.AsString.LCase.Substitute(" ","_") if (enforce) then theFile = scriptName.AsString.LCase.Substitute("","_") outFile = FN.Make(saveDirStr).MakeTmp(theFile, "ave") else theFile = scriptName.AsString.Substitute(" ","_") 'theFile = scriptName.AsString.LCase.Substitute(" ","_") outFile = FileName.Merge(saveDirStr, theFile) outFile.SetExtension("ave") if (outFile.IsFile) then ok = MsgBox.YesNoCancel("Overwrite"++outFile.GetFullName+"?", "Save Scripts", true) if (ok = Nil) then exit elseif (Not ok) then continue end end end lf = LineFile.Make(outFile, #FILE_PERM_WRITE) if (lf <> nil) then lf.WriteElt(scriptName.GetScript.AsString) lf.Close else MsgBox.Warning("Unable to write:"++outFile.GetFullName,"") end end av.GetProject.SetWorkDir(oldDir) av.ShowMsg("Script(s) written to:"++saveDirStr) '----end of script---------------------------------------------------