'CONVERTS MULTIPLE ASCII GRIDS INTO A SINGLE CSV FILE FOR INPUT INTO POSSIBLE STATISTICAL ANALYSES 'FIRES FROM THE SCRIPT DOCUMENT ITSELF 'LOADING SCRIPTS ' 1. Double-click on an empty area on the bar containing all buttons, The "Customize" dialog appears ' 2. In the "Type" pull-down, select "View" ' 3. In the "Category" pull-down, select "Buttons", The display right below the pull down changes to show an array of buttons ' 4. Slide the scrollbar (below the button display) to the right and select the last button by clicking on it, Now click on "New" ' 5. A new blank button appears. Double-click on the blank area to the right of the entry "Click" (just below the button display) ' 6. The "Script Manager" Dialog appears, Click on "New", Enter any name in the input box that appears (prefix it with "Z_" so that it goes in the last) ' 7. A new blank script document (With the name just specified) appears. Delete whatever is on it... ' 8. Either copy-paste this ENTIRE script on the document, or, click on the button with the open-folder icon (tooltip reads "Load text file") and navigate to this file ' 9. Either done, click on the button with the tick-mark icon ("compile"). If spatial analyst is not loaded, there will be some error message, Load it ' 10. After the script is compiled (the tick-mark buton should be grayed out), close the script window and return to the view ' 11. Click on the new button to run the script aFName=FileDialog.Put("DataMatrix.csv".AsFileName,"*.csv","Specify Data Matrix File Location") aLF=LineFile.Make(aFName,#FILE_PERM_WRITE) TheFiles=FileDialog.ReturnFiles({"*.asc"},{"ASCII Files"},"Specify ASCII Files",0) ListofLists={} for each f in TheFiles TempF=LineFile.Make(f,#FILE_PERM_READ) ThefSize=TempF.GetSize Ctr=6 WriteStr="" Tempf.SetPos(Ctr) For each i in 6..(TheFSize-1) TempF.SetPos(i) TheStr=Tempf.ReadELT Cols=TheStr.AsList.Count NewStr=TheStr.Substitute(" ",",") WriteStr=WriteStr+NewStr end TheName=f.GetBaseName.AsString Fstub=TheName.Left(TheName.Count-4) WriteStr=Fstub+","+WriteStr WriteStr=WriteStr.Left(WriteStr.Count-1) TempList=WriteStr.AsTokens(",") ListofLists.Add(TempList) end Rows=TheFSize-6 EdgeYN=0 for each l in 0..(TempList.Count-1) NewStr="" for each t in 0..(ListofLists.Count-1) NewStr=NewStr+ListofLists.Get(t).Get(l)+"," end if (l=0) then aLF.WriteELT("Edge"+","+"Index"+","+NewStr.Left(NewStr.Count-1)) else if ((l<=Cols) OR (l>=((Cols*Rows)-Cols)) OR (((l/Cols).Truncate-(l/Cols))=0) OR ((((l+1)/Cols).Truncate-((l+1)/Cols))=0)) then EdgeYN=0 aLF.WriteELT(EdgeYN.AsString+","+l.AsString+","+NewStr.Left(NewStr.Count-1)) else EdgeYN=1 aLF.WriteELT(EdgeYN.AsString+","+l.AsString+","+NewStr.Left(NewStr.Count-1)) end end end