Print date and time header on layouts

It is sometimes helpful to have the date and time print on layouts you create so that later on you know when the page was printed and you can compare multiple copies of the same thing to see which one was printed most recently.

As of this writing, Igor Pro does not have the capability to automatically print a header or footer on every printed page. However, using a bit of code, you can simulate this behavior.

For example, if you create a layout and execute the following lines you will have a text box at the upper left corner of the layout which contains the date and time. When you select File | Print to print the layout, the time and date will be updated before the layout is printed (assuming you also have copied the function below into a procedure file that is opened in your current experiment).
String infoBox
infoBox = "\{\"%s %s\", Secs2Date(DateTime, 0), Secs2Time(DateTime, 3)}"
TextBox/C/N=infoBox/F=0/A=LT/X=0/Y=0 infoBox


The code that creates this text box uses dynamic escape codes. For more information on how to use dynamic escape codes, execute the following command from the Igor Pro command window:
DisplayHelpTopic "Other Dynamic Escape Codes"


In order for this text box to be updated every time the layout is printed, the function below should be copied into a procedure file in each experiment you want to be able to print this information. You can also copy the function into a procedure file and save that file (or a shortcut to it) in your Igor Pro Folder:Igor Procedures folder/directory. This function only updates any annotations on a layout when the layout is printed. You need to first add an annotation to the layout with the information you want (as in the example above).

Function IgorMenuHook(isSel, menuStr, itemStr, itemNo, topWindowName, wt)
    Variable isSel
    String menuStr, itemStr
    Variable itemNo
    String topWindowName
    Variable wt

    if (cmpstr(menuStr, "File") == 0 && cmpstr(itemStr, "Print") == 0)
        if (wt == 3)        // only respond if a layout is about to be printed
            String annotations = AnnotationList(topWindowName)
            Variable n, numAnnotations = ItemsInList(annotations, ";")
            String currentAnnotation, currentAnnotationInfo, annotationType
            For (n=0; n<numAnnotations; n+=1)
                currentAnnotation = StringFromList(n, annotations, ";")
                currentAnnotationInfo = AnnotationInfo(topWindowName, currentAnnotation)
                annotationType = StringByKey("TYPE", currentAnnotationInfo, ":", ";")
                StrSwitch (annotationType)
                    Case "Tag":
                        Tag/W=$(topWindowName)/C/N=$(currentAnnotation)
                        break
                    Case "Textbox":
                        Textbox/W=$(topWindowName)/C/N=$(currentAnnotation)
                        break
                    Case "ColorScale":
                        ColorScale/W=$(topWindowName)/C/N=$(currentAnnotation)
                        break
                    Case "Legend":
                        Legend/W=$(topWindowName)/C/N=$(currentAnnotation)
                        break
                EndSwitch
            EndFor
        endif
    endif
   
    return 0
End


If you want to add text boxes to graphs and you also want those to be updated before printing, you need to make a minor modification to the function above. Find the line that reads:
if (wt == 3)        // only respond if a layout is about to be printed

and change it to this line:
if (wt == 3 || wt == 2)     // only respond if a layout or a graph is about to be printed

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More