source: specdomain/trunk/src/specdomain/doc/example.mac @ 1007

Last change on this file since 1007 was 1007, checked in by jemian, 10 years ago

refs #8, much, MUCH better reporting, almost ready for release, need to improve the "howto" documentation in the docs/ subdir

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision URL Header
File size: 1.8 KB
Line 
1
2########### SVN repository information ###################
3# $ Date: 2011-09-16 13:04:57 -0500 (Fri, 16 Sep 2011) $
4# $ Author: jemian $
5# $ Revision: 463 $
6# $ HeadURL: https://subversion.xor.aps.anl.gov/spec/beamline_config/trunk/usaxs/usaxs/usaxs_load.mac $
7# $ Id: usaxs_load.mac 463 2011-09-16 18:04:57Z jemian $
8########### SVN repository information ###################
9
10"""
11Example SPEC Macro Source code file for demonstration purposes only.
12
13::
14
15        $Id: example.mac 1007 2012-07-12 22:56:32Z jemian $
16
17This file is used to demonstrate how to document SPEC [#]_ macro files
18using Sphinx [#]_ and restructured text (reST) [#]_ markup.
19
20Provides:
21
22* :spec:def:`inc1scan`
23* :spec:def:`CheckSaveToFile`
24
25.. rubric::  Footnote
26.. [#] SPEC:   http://www.certif.com
27.. [#] Sphinx: http://sphinx.pocoo.org/
28.. [#] reST:   http://docutils.sf.net/rst.html
29
30-------------
31"""
32
33global example_global  #: this is an example of a global variable
34local  example_local   #: a local variable is unusual at the global level
35
36#: Conversion constant between wavelength (A) and photon energy (keV)
37constant  A_keV 12.3984
38
39def inc1scan '{
40        """specify a single motor scan with interval rather than # of intervals"""
41        if ($# != 5) {
42                print "Usage:  inc1scan  motor start finish increment time"
43                exit
44        }
45        ascan $1 $2 $3 fabs(($3-$2)/$4)+0.5 $5
46}'
47
48def CheckSaveToFile '{
49  """
50  This macro will run when SPEC starts and checks
51  if the output is directed into a file or might be ignored.
52  It runs :spec:def:`newsample` if the output might be ignored.
53  """
54  if (unset("DATAFILE") || (DATAFILE == "/dev/null") || (DATAFILE == "null")) {
55    print "!!!You have not started to save your data to a file!!!"
56    print "(newsample)"
57    # prompt the user for a data file
58    newsample
59  }
60}'
61#: register CheckSaveToFile to run on startup
62cdef("begin_mac", "CheckSaveToFile\n", "CheckSaveToFile", 0x20)
Note: See TracBrowser for help on using the repository browser.