source: trunk/builder/scripts/templates/r.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.0 KB
Line 
1# ----------------------------------------------------------------------
2#  LANGUAGE:  R Language 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 "R Language" {
11  extension ".R"
12
13  command {R --slave --no-save --no-restore --silent --args @driver < @tool/@@FILENAME@@}
14
15  main {# ----------------------------------------------------------------------
16#  MAIN PROGRAM - generated by the Rappture Builder
17# ----------------------------------------------------------------------
18require(Rappture)
19
20# open the XML file containing the run parameters
21args <- commandArgs()
22
23# command line: R --slave --no-save --no-restore --silent --args @driver
24#               ^1     ^2        ^3           ^4       ^5     ^6      ^7
25io <- rp_lib(args[7])
26
27#########################################################
28# Get input values from Rappture
29#########################################################
30@@INPUTS@@
31
32#########################################################
33#  Add your code here for the main body of your program
34#########################################################
35
36
37#########################################################
38# Save output values back to Rappture
39#########################################################
40@@OUTPUTS@@
41
42rp_lib_result(io)
43quit("no",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 "$id <- rp_lib_get_string(io,\"$path.current\") == \"yes\""
50  }
51  input image {
52    code "\n# get input value for $path"
53    code "# returns base64-encoded image data"
54    code "imdata <- rp_lib_get_string(io, \"$path.current\")"
55  }
56  input number {
57    set units [attr get units]
58    if {$units ne ""} {
59      code "\n# get input value for $path and convert to $units"
60      code "str <- rp_lib_get_string(io, \"$path.current\")"
61      code "$id <- rp_units_convert_double(str,\"$units\")"
62    } else {
63      code "\n# get input value for $path"
64      code "$id <- rp_lib_get_string(io, \"$path.current\")"
65    }
66  }
67  input * {
68    code "\n# get input value for $path"
69    code "$id <- rp_lib_get_string(io, \"$path.current\")"
70  }
71
72  output curve {
73    code "\n# save output value for $path"
74    code "# assumes output in vectors x and y"
75    code "str <- paste(sprintf(\"%g %g\\n\",x,y), collapse=\"\")"
76    code "rp_lib_put_string(io,\"$path.component.xy\",str,FALSE)"
77  }
78  output histogram {
79    code "\n# save output value for $path"
80    code "# assumes output in vectors x and y"
81    code "str <- paste(sprintf(\"%g %g\\n\",x,y), collapse=\"\")"
82    code "rp_lib_put_string(io,\"$path.component.xy\",str,FALSE)"
83  }
84  output * {
85    code "\n# save output value for $path"
86    code "rp_lib_put_string(io,\"$path.current\",$id,FALSE)"
87  }
88}
Note: See TracBrowser for help on using the repository browser.