/* Outputs information that might be useful for debugging to log window Peter J. Lee NHMFL/FSU v210422 first version v230803: Replaced getDir for 1.54g10. v240624: Uses ASC function. Also REQUIRES findAppPath function. */ lMacro = "Debug_info_to_log_v240624-f1.ijm"; IJ.log(getSystemInfo()); function findAppPath(appName, appEx, defaultPath) { /* v210921 1st version: appName is assumed to be the app folder name, appEx is the executable, default is the default return value v211018: assumes specific executable path stored in prefs Prints message rather than exits when app not found v211213: fixed defaultPath error v211214: Adds additional location as packaged within a Fiji/IJ distribution v220121: Changed fS line v230803: Replaced getDir with getDirectory for ImageJ 1.54g10 v260603: Adds Appdata path and beautifies. v260604: add missing username. */ functionL = "findAppPath_v260604"; fS = File.separator; ijPath = getDirectory("imagej"); appsPath = substring(ijPath, 0, lengthOf(ijPath) - 1); appsPath = substring(appsPath, 0, lastIndexOf(appsPath, fS)); appFound = false; prefsName = "asc.external.paths." + toLowerCase(appName) + "." + appEx; appPath = call("ij.Prefs.get", prefsName, defaultPath); appLoc = "" + fS + appName + fS + appEx; cProg = "C:" + fS + "Program Files"; username = getInfo("user.name"); defAppPaths = newArray(ijPath + "Apps", "C:" + fS + "Users" + fS + username + fS + "AppData" + fS + "Local" + fS + "Programs" + fS + "ImageMagick", cProg + fS + "Utilities", cProg + " \(x86\)" + fS + "Utilities", cProg, cProg + " \(x86\)", appsPath); if (!File.exists(appPath)) { for (i = 0; i < lengthOf(defAppPaths); i++) { if (File.exists(defAppPaths[i])) { appPath = defAppPaths[i]; call("ij.Prefs.set", prefsName, appPath); appFound = true; i = lengthOf(defAppPaths); } } } else appFound = true; if (appFound == false) { Dialog.create("Find location of " + appEx + " version: " + functionL); Dialog.addMessage(appEx + " can provide additional functionality to this macro\nbut has not been found in the expected locations"); Dialog.addCheckbox("Get me out of here, I don't want to try and find " + appName + ", whatever that is", false); Dialog.addFile("Locate " + appEx + ":", "C:" + fS + "Program Files"); Dialog.addMessage("If found, the location will be saved in prefs for future use:\n" + prefsName); Dialog.show; if (Dialog.getCheckbox) appFound = false; else { appPath = Dialog.getString(); if (!File.exists(appPath)) print(appEx + " not found"); else { call("ij.Prefs.set", prefsName, appPath); appFound = true; } } } if (appFound) return appPath; else return defaultPath; } function getSystemInfo() { lfunction = "getSystemInfo_v240624"; os = getInfo("os.name"); win = startsWith(os, "Windows"); javaV = "" + getInfo("java.runtime.version"); javaVendor = getInfo("java.vendor"); fS = File.separator; memMax = IJ.maxMemory(); memMax /= 1000000; gSPath = findAppPath("Gifsicle","gifsicle.exe","not found"); iMConvPath = findAppPath("ImageMagick","magick.exe","not found"); gnuWin32Path = findAppPath("GnuWin32"+fS+"bin","tiffsplit.exe","not found"); /* This section shortens directory paths using the common base ImageJ directory if possible */ userDirL = getInfo("user.dir"); username = getInfo("user.name"); imageJDir = getDirectory("imagej"); javaHDir = replace(getInfo("java.home"),"/",fS); if (startsWith(javaHDir, imageJDir)) javaHDir = " ..." + substring(javaHDir, lengthOf(imageJDir)) + " "; else javaHDir = javaHDir + "\n"; javaCP = replace(getInfo("java.class.path"),"/",fS); if (startsWith(javaCP, imageJDir)) javaCP = " ..." + substring(javaCP, lengthOf(imageJDir)); else javaCP = javaCP + "\n"; pluginsDir = getDirectory("plugins"); if (startsWith(pluginsDir, imageJDir)) pluginsDir = " ..." + substring(pluginsDir, lengthOf(imageJDir)) + " "; else pluginsDir = pluginsDir + "\n"; macrosDir = getDirectory("macros"); if (File.exists(macrosDir + "runAtStartup.ijm")) rASModString = " \(date: " + File.dateLastModified(macrosDir + "runAtStartup.ijm") + "\)"; else rASModString = ""; if (File.exists(macrosDir + "StartupMacros.fiji.ijm")) sMString = "\nFiji startup last modified: " + File.dateLastModified(macrosDir + "StartupMacros.fiji.ijm"); else if (File.exists(macrosDir + "StartupMacros.ijm")) sMString = "\nImageJ startup last modified: " + File.dateLastModified(macrosDir + "StartupMacros.ijm"); else sMString = ""; if (startsWith(macrosDir, imageJDir)) macrosDir = " ..." + substring(macrosDir, lengthOf(imageJDir)); /* End of abbreviation section */ systemInfoTxt = "ImageJ Version: " + IJ.getFullVersion + " \(" + getVersion() + "\)" + "\nMemory status: " + IJ.freeMemory() + ", IJ assigned max: " + memMax + " MB" + "\nJava: " + getInfo("java.runtime.name") + "\n Java version: " + javaV + "\n Java Vendor: " + javaVendor + "\nCharacter encoding: " + getInfo("file.encoding") + " \(ASC macros should be Cp-1252\)" + "\nOperating system: " + getInfo("os.name") + " \(ASC macros only tested in Windows\)" + "\nUser name: " + username + "\nUser home: " + getInfo("user.home") + "\nIJ prefs: \\.imagej" + "\nUser directory: " + userDirL + "\nImageJ directory: " + imageJDir + "\nJava home dir.: " + javaHDir + "\nJava class path: " + javaCP + "\)" + "\nPlugins directory: " + pluginsDir + "\nMacros directory: " + macrosDir + "\nGifsicle path: " + gSPath + "\nImageMagick Convert path: " + iMConvPath + "\nGnuWin32 path: " + gnuWin32Path + "\nRun at startup pop-up menu: " + rASModString + sMString + "\n---------------\n"; return systemInfoTxt; }