#pragma rtGlobals=1 // Use modern global access method. Function LoadFiles() String mode = "CAPS_Choose_Files" // "CAPS_Choose_Files", "CAPS_Choose_Dir", "CAPS_Search_Dirs" Variable i, fileNum, firstDataLine, isData String currentFile String columnLabel String tmpWaveList String currentWave // Get lists of files to load FileList(mode) // Load GRIMM time series if(WaveExists(CASTSPaths)) sort /A CASTSPaths, CASTSPaths tmpWaveList = "" fileNum = 0 isData = 0 for(i =0;i 1) Variable folderIndex = 0 Variable numFolders = ItemsInList(scannedDirs, "\r") do // Scan all directories for all files currentDir = StringFromList(folderIndex, scannedDirs, "\r") NewPath /C /O /Z /Q pathName currentDir PathInfo pathName fileNames += Files(s_path) folderIndex = folderIndex + 1 while(folderIndex < numFolders) fileNames = ReplaceString("\r\r", fileNames, "\r") return fileNames End Function/S Folders(searchPath) String searchPath String unscannedDirs = "" NewPath /C /O /Z /Q currentPath searchPath Variable index = 0 do unscannedDirs += IndexedDir(currentPath,index,1) + "\r" index = index + 1 while((strlen(IndexedDir(currentPath,index,1))) >= 1) unscannedDirs = ReplaceString("\r\r", unscannedDirs, "\r") Return unscannedDirs End Function/S Files(searchPath) String searchPath String fileSearch = "" NewPath /C /O /Z /Q currentPath searchPath Variable index = 0 do fileSearch += searchPath + IndexedFile(currentPath,index,"????") + "\r" index = index + 1 if(index>200) String errStr = "There's a directory in here which contains more than 200 files. These are unlikely to be PADS data files, - they may instead be processed image files for example. Stopping the search for this directory and continuing with next." DoAlert 0, errStr break endif while((strlen(IndexedFile(currentPath,index,"????"))) != 0) Return fileSearch End Function FindFirstDataLine(currentFile) String currentFile Variable refNum Variable lineNumber = 0 String text = "" Open/R refNum as currentFile do FReadLine refNum, text FStatus refNum if (!GrepString(text, "[(?i)A-Z*][^NaN]") && strlen(text) > 3 && lineNumber > 180) break endif if (V_filePos == V_logEOF) lineNumber = -1 break endif lineNumber += 1 while(1) Close refNum return lineNumber End