Example Use of Package Tools StartorNewHook Function

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/Z 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

Forum

Support

Gallery

Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More