Example Use of Package Tools StartorNewHook Function
Posted June 23rd, 2010 by jjweimer
This shows how to use information stored by Package Tools to check for information about a given package loaded in an experiment. You must have installed the package Package Tools in the Igor Procedures folder. Put this code at the start of your procedure file for your package. Modify it according to your needs.
// package parameters Static StrConstant thePackage="YourPackageNameHere" Static StrConstant thePackageFolder="YourPackageFolderHere" Static StrConstant theProcedureFile = "YourPackageProcedureFileHere.ipf" Static StrConstant thePackageInfo = "This is what your package does" Static StrConstant thePackageAuthor = "Your Name Here" Static Constant thePackageVersion = 1.0 Static Constant hasHelp = 0 // 0-no; 1-yes (called by DisplayHelpTopic "YourPackageName" // hook function (at top of procedure file for you package) Static Function AfterFileOpenHook(refNum,file,pathName,type,creator,kind) Variable refNum,kind String file,pathName,type,creator SVAR pt = root:Packages:PackageTools:AnnotationTools string theCmd if (!SVAR_Exists(pt)) // initialize package information DFREF cdf = GetDataFolderDFR() NewDataFolder/O/S Packages NewDataFolder/O PackageTools SetDataFolder cdf sprintf theCmd, "PackageSetup(\"%s\",file=\"%s\",info=\"%s\",author=\"%s\",version=%g,hasHelp=%d)", thePackage,theProcedureFile,thePackageInfo,thePackageAuthor,thePackageVersion,hasHelp // use the execute method to allow this to work in Independent Modules Execute/P/Q/Z theCmd else // package parameter is already installed // do other things here depending on your package endif return 0 end
