source: branches/uq/lang/R/Rappture/src/RpUtilsRInterface.cc @ 4644

Last change on this file since 4644 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: 1.7 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: R Rappture Utils Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#include "RpUtils.h"
15#include "RpUtilsRInterface.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/**********************************************************************/
22// FUNCTION: RPRUtilsProgress(percent,handle)
23/// Send the =RAPPTURE-PROGRESS=> message to stdout for the progress widget
24/**
25 */
26
27SEXP
28RPRUtilsProgress(SEXP percent, SEXP message)
29{
30    SEXP ans;
31    int err = 0;
32    int percentInt = 0;
33
34    ans = allocVector(INTSXP,1);
35    PROTECT(ans);
36
37    INTEGER(ans)[0] = -1;
38
39    if (length(percent) != 1) {
40        error("percent is not a scalar value");
41        UNPROTECT(1);
42        return ans;
43    }
44
45    if (isReal(percent)) {
46        percentInt = (int) asReal(percent);
47    } else if (isInteger(percent)) {
48        percentInt = asInteger(percent);
49    } else {
50        error("percent is not an integer");
51        UNPROTECT(1);
52        return ans;
53    }
54
55    if (!isString(message) || length(message) != 1) {
56        error("message is not a single string");
57        UNPROTECT(1);
58        return ans;
59    }
60
61    err = Rappture::Utils::progress(percentInt,CHAR(STRING_ELT(message,0)));
62
63    INTEGER(ans)[0] = err;
64
65    UNPROTECT(1);
66
67    return ans;
68}
69
70#ifdef __cplusplus
71}
72#endif // ifdef __cplusplus
73
Note: See TracBrowser for help on using the repository browser.