#pragma rtGlobals=3 // Use modern global access method and strict wave access. Menu "Load Waves" "Load One RND File...", LoadOneRNDFile("", "") "Load All RND Files...", LoadAllRNDFilesDF("") End static StrConstant kFileNameExtension = ".txt" static Function/S GetColumnInfoStr() String columnInfoStr = " " columnInfoStr += "N='depth_for_growth';" // 1 columnInfoStr += "N='growthp_3';" // 2 columnInfoStr += "N='_skip_';" // 3 growthp_17 columnInfoStr += "N='growthp_50';" // 4 columnInfoStr += "N='_skip_';" // 5 growthp_83 columnInfoStr += "N='growthp_97';" // 6 columnInfoStr += "N='age_for_rate';" // 7 columnInfoStr += "N='_skip_';" // 8 ratep_3 columnInfoStr += "N='_skip_';" // 9 ratep_17 columnInfoStr += "N='ratep_50';" // 10 columnInfoStr += "N='_skip_';" // 11 ratep_83 columnInfoStr += "N='_skip_';" // 12 ratep_97 columnInfoStr += "N='age_for_age_err';" // 13 columnInfoStr += "N='AgeMinusErr';" // 14 columnInfoStr += "N='_skip_';" // 15 AgeMinusErr1SE columnInfoStr += "N='_skip_';" // 16 AgePlusErr1SE columnInfoStr += "N='AgePlusErr';" // 17 return columnInfoStr End // LoadOneRNDFile(pathName, fileName) Function LoadOneRNDFile(pathName, fileName) String pathName // Name of an Igor symbolic path or "" for dialog String fileName // Name of file or full path to file or "" for dialog // First get a valid reference to a file. if ((strlen(pathName)==0) || (strlen(fileName)==0)) // Display dialog looking for file. Variable refNum Open/D/R/F=kFileNameExtension/P=$pathName refNum as fileName fileName = S_fileName // S_fileName is set by Open/D if (strlen(fileName) == 0) // User cancelled? return -1 endif endif String columnInfoStr = GetColumnInfoStr() LoadWave /G /O /D /K=0 /A /B=columnInfoStr /Q /P=$pathName fileName Variable numWavesLoaded = V_flag // V_flag is set by LoadWave Variable numWavesToBeLoaded = 9 if (numWavesLoaded != numWavesToBeLoaded) Printf "Error loading file: Expected %d waves, found %d waves\r" return -1 endif return 0 // Success End // LoadAllRNDFilesDF(pathName) // Loads all files in specified folder with extension specified by kFileNameExtension. Function LoadAllRNDFilesDF(pathName) String pathName // Name of symbolic path or "" to get dialog String fileName Variable index=0 if (strlen(pathName)==0) // If no path specified, create one NewPath/O TemporaryPath // This will put up a dialog if (V_flag != 0) return -1 // User cancelled endif pathName = "TemporaryPath" endif Variable result do // Loop through each file in folder fileName = IndexedFile($pathName, index, kFileNameExtension) if (strlen(fileName) == 0) // No more files? break // Break out of loop endif // Data folder name is file name with extension removed String dfName = ParseFilePath(3, fileName, ":", 0, 0) NewDataFolder/O/S $dfName result = LoadOneRNDFile(pathName, fileName) SetDataFolder :: if (result != 0) String message sprintf message, "An error occurred while loading the file \"%s\". Aborting the load.\r", fileName Print message DoAlert 0, message break endif Printf "Loaded file %d: \"%s\"\r", index, fileName index += 1 while (1) if (Exists("TemporaryPath")) // Kill temp path if it exists KillPath TemporaryPath endif return 0 // Signifies success End