source: trunk/builder/scripts/templates/tcl.tl @ 3177

Last change on this file since 3177 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:  Tcl 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 "Tcl" {
11  extension ".tcl"
12  command {tclsh @tool/@@FILENAME@@ @driver}
13
14  main {# ----------------------------------------------------------------------
15#  MAIN PROGRAM - generated by the Rappture Builder
16# ----------------------------------------------------------------------
17package require Rappture
18
19# open the XML file containing the run parameters
20set io [Rappture::library [lindex $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 -mesg "Starting..."
33Rappture::Utils::progress 5 -mesg "Loading data..."
34Rappture::Utils::progress 50 -mesg "Half-way there"
35Rappture::Utils::progress 100 -mesg "Done"
36
37#########################################################
38# Save output values back to Rappture
39#########################################################
40@@OUTPUTS@@
41
42Rappture::result $io
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 "set $id \[\$io get $path.current\]"
50  }
51  input image {
52    code "\n# get input value for $path"
53    code "# returns base64-encoded image data"
54    code "set imdata \[\$io get $path.current\]"
55    code "set $id \[image create photo -data \$imdata\]"
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 "set str \[\$io get $path.current\]"
62      code "set $id \[Rappture::Units::convert \$str -to $units -units off\]"
63    } else {
64      code "\n# get input value for $path"
65      code "set $id \[\$io get $path.current\]"
66    }
67  }
68  input * {
69    code "\n# get input value for $path"
70    code "set $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 -append yes $path.component.xy \"\$x \$y\\n\""
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 -append yes $path.component.xy \"\$x \$h \$w\\n\""
83  }
84  output image {
85    code "\n# save output value for $path"
86    code "# this assumes that \$imh is the handle for a Tk photo image"
87    code "\$io put $path.current \[\$imh data -format gif\]"
88  }
89  output * {
90    code "\n# save output value for $path"
91    code "\$io put $path.current \$id"
92  }
93}
Note: See TracBrowser for help on using the repository browser.