'--------------------------------- 'Name: asc2grid.bat 'Date: 1-10-01 'Author: Marco Morais ' ' prompts the user for ascii raster files on disk ' ' converts each ascii raster file to a grid in same directory ' 'Returns: 'NILL ' 'Called By: 'MANY ' 'Calls: 'None ' 'Arguments: 'None '--------------------------------- MsgBox.Report("asc2grid.bat" + NL + "1. prompts the user for ascii raster files on disk" + NL + "2. converts each ascii raster file to a grid of " + NL + " same name in same directory", "About Script....") '--------------------------------------- 'retrieve list of ascii raster files '--------------------------------------- theASCIIRasterFileNameList = FileDialog.ReturnFiles({"*.asc"}, {"ASCII Raster(*.asc)"}, "Select ASCII Raster Files to Import As Grids", 0) if ( theASCIIRasterFileNameList.Count = 0 ) then return NIL end '----------------------------------------------------------- 'determine whether rasters to be imported as ints or floats '----------------------------------------------------------- isInt = MsgBox.YesNo("Import the ASCII raster files as INTs (YES-default) or FLOATs (NO).", "INT or FLOAT Grids?", TRUE) '--------------------------------------------------- 'convert the ascii raster filenames to grid strings '--------------------------------------------------- theGridToConvertFileStringList = List.Make for each arf in theASCIIRasterFileNameList theFileString = arf.AsString.AsTokens(".").Get(0) theGridToConvertFileStringList.Add(theFileString) end '------------------------------------------------------ 'load each of the ascii raster files and save to disk '------------------------------------------------------ theConvertedGridList = List.Make i = 0 for each arf in theASCIIRasterFileNameList theGrid = Grid.MakeFromASCII(arf, isInt.Not) theGTheme = GTheme.Make(theGrid) if (theGrid.HasError) then MsgBox.Error("Grid not able to be created", "Error") continue end theGrid.SaveDataSet(theGridToConvertFileStringList.Get(i).AsFileName) theConvertedGridList.Add(theGrid) i = i + 1 end av.PurgeObjects return NIL