Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# TraverseSubDirs.sml
# Cindy Robbins 4 Oct 2006
# Demonstratesa way to navigate through directories, subdirectories and RVC files
# looks in directory for RVC file and prints all raster names; then goes through sub directories & does the same
clear();
#class FILEPATH myPath = "c:/NavigateTest"; # starting directory
class FILEPATH myPath = GetDirectory("c:/data", "Get starting directory ...");
class StatusHandle statusHandle;
proc GetFiles(class FILEPATH inP, class STRING dirs) {
class STRINGLIST files;
class STRINGLIST rasters;
string filename$;
files = inP.GetFileList();
numeric i, n;
string filename$, desc$, log$;
for i = 0 to files.GetNumItems() -1 {
filename$ = inP.GetPath() +"/"+ files[i];
if (right$(filename$, 3) =="rvc") {
print("rasters in : ", filename$, " ...");
rasters = GetAllObjectNames(filename$, "RASTER");
for n = 0 to rasters.GetNumItems() -1{
OpenRaster(R, filename$, rasters.GetString(n));
print(" ", rasters.GetString(n), " Type: ",R.$Info.Type);
}
}
}
}
proc GetFolders(class FILEPATH inPath ) {
local class STRINGLIST directories = inPath.GetDirectoryList();
local numeric j;
if (directories.GetNumItems() > 0) {
for j = 0 to directories.GetNumItems() - 1 {
inPath = inPath.GetPath() + "/"+ directories[j];
GetFiles(inPath, directories[j]);
if (inPath.GetDirectoryList().GetNumItems() > 0) {
GetFolders(inPath);
}
inPath.StripLastComponent();
}
}
}
GetFiles(myPath);
GetFolders(myPath);
print("done");