source: tags/20100403/lang/octave/rpUnitsGetUnits.cc @ 1687

Last change on this file since 1687 was 1262, checked in by dkearney, 15 years ago

attempting to fix compiler warning for octave's print_usage function
this seems to work for octave3.0
also adding checks to configure for more header files

File size: 2.4 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpUnitsGetUnits(unitHandle)
6 *
7 * ======================================================================
8 *  AUTHOR:  Derrick Kearney, Purdue University
9 *  Copyright (c) 2005
10 *  Purdue Research Foundation, West Lafayette, IN
11 * ======================================================================
12 */
13
14#include "RpOctaveInterface.h"
15
16/**********************************************************************/
17// METHOD: [retStr,err] = rpUnitsGetUnits(unitHandle)
18/// Return the units of the Rappture Unit represented by unitHandle.
19/**
20 * Retrieve the units of the Rappture Units object with the handle
21 * 'unitHandle'. Note this does not include the exponent.
22 * For units and exponent in one string see rpUnitsGetUnitsName().
23 * Return the units as a string.
24 * Error code, err=0 on success, anything else is failure.
25 */
26
27DEFUN_DLD (rpUnitsGetUnits, args, ,
28"-*- texinfo -*-\n\
29[retVal,err] = rpUnitsGetUnits(@var{unitHandle})\n\
30\n\
31Retrieve the units of the Rappture Units object with the handle \n\
32'unitHandle'. Note this does not include the exponent.\n\
33For units and exponent in one string see rpUnitsGetUnitsName().\n\
34Return the units as a string.\n\
35Error code, err=0 on success, anything else is failure.")
36{
37    static std::string who = "rpUnitsGetUnits";
38
39    // The list of values to return.
40    octave_value_list retval;
41    int err = 1;
42    int nargin = args.length ();
43
44    const RpUnits* myUnit = NULL;
45    int unitHandle = 0;
46    std::string retStr = "";
47
48    if (nargin == 1) {
49
50        if ( args(0).is_real_scalar() ) {
51
52            unitHandle = args(0).int_value ();
53
54            /* Call the C subroutine. */
55            if ( unitHandle >= 0 ) {
56
57                // get the original unit
58                myUnit = getObject_UnitsStr(unitHandle);
59                if (myUnit) {
60                    // get the basis
61                    retStr = myUnit->getUnits();
62                    // adjust error code
63                    err = 0;
64                }
65            }
66            else {
67                // invalid unitHandle
68                _PRINT_USAGE (who.c_str());
69            }
70        }
71        else {
72            _PRINT_USAGE (who.c_str());
73        }
74    }
75    else {
76        _PRINT_USAGE (who.c_str());
77    }
78
79    retval(0) = retStr;
80    retval(1) = err;
81    return retval;
82}
Note: See TracBrowser for help on using the repository browser.