source: trunk/builder/scripts/templates/perl.tl

Last change on this file was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 3.2 KB
Line 
1# ----------------------------------------------------------------------
2#  LANGUAGE:  Perl API
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
6#
7#  See the file "license.terms" for information on usage and
8#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9# ======================================================================
10language "Perl" {
11  extension ".pl"
12  command {perl @tool/@@FILENAME@@ @driver}
13
14  main {# ----------------------------------------------------------------------
15#  MAIN PROGRAM - generated by the Rappture Builder
16# ----------------------------------------------------------------------
17use Rappture;
18
19# open the XML file containing the run parameters
20$io = Rappture::RpLibrary->new($ARGV[0]);
21
22#########################################################
23# Get input values from Rappture
24#########################################################
25@@INPUTS@@
26
27#########################################################
28#  Add your code here for the main body of your program
29#########################################################
30
31# spit out progress messages as you go along...
32Rappture::Utils::progress(0, "Starting...");
33Rappture::Utils::progress(5, "Loading data...");
34Rappture::Utils::progress(50, "Half-way there");
35Rappture::Utils::progress(100, "Done");
36
37#########################################################
38# Save output values back to Rappture
39#########################################################
40@@OUTPUTS@@
41
42$io->result();
43exit 0;
44}
45
46  input boolean {
47    code "\n# get input value for $path"
48    code "# returns value as string \"yes\" or \"no\""
49    code "\$str = \$io->get(\"$path.current\");"
50    code "\$$id = (\$str) ? \"yes\" : \"no\";"
51  }
52  input image {
53    code "\n# get input value for $path"
54    code "# returns base64-encoded image data"
55    code "\$$id = \$io->get(\"$path.current\");"
56  }
57  input number {
58    set units [attr get units]
59    if {$units ne ""} {
60      code "\n# get input value for $path and convert to $units"
61      code "\$str = \$io->get(\"$path.current\");"
62      code "$$id = Rappture::RpUnits::convert(\$str, \"$units\", \"off\");"
63    } else {
64      code "\n# get input value for $path"
65      code "\$$id = \$io->get(\"$path.current\");"
66    }
67  }
68  input * {
69    code "\n# get input value for $path"
70    code "\$$id = \$io->get(\"$path.current\");"
71  }
72
73  output curve {
74    code "\n# save output value for $path"
75    code "# this shows just one (x,y) point -- modify as needed"
76    code "\$io->put(\"$path.component.xy\", \"\$x \$y\\n\", 1);"
77  }
78  output histogram {
79    code "\n# save output value for $path"
80    code "# this shows just one point -- modify as needed"
81    code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)"
82    code "\$io->put(\"$path.component.xhw\", \"\$x \$h \$w\\n\", 1);"
83  }
84  output image {
85    code "\n# save output value for $path"
86    code "# data in \$$id should be base64-encoded image data"
87    code "\$io->put(\"$path.current\", \$$id, 0);"
88  }
89  output * {
90    code "\n# save output value for $path"
91    code "\$io->put(\"$path.current\", \$$id, 0);"
92  }
93}
Note: See TracBrowser for help on using the repository browser.