source: trunk/src/octave/rpUnitsGetUnitsName.cc @ 511

Last change on this file since 511 was 135, checked in by dkearney, 19 years ago

1) fixed children function in c++'s library module so users can now
search for children by type.
2) adjusted bindings dictionary module for storing lib's to allow caller
to set the key of the value being stored.
3) removed old targets for rappture_interface.o and rappture_fortran.o
from makefile
4) renamed matlab and octave binding functions names to match the module
they came from.
5) adjusted matlab/octave example in examples/app_fermi/matlab
6) added matlab and octave search paths environment variables to
gui/apps/rappture

File size: 2.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Octave Rappture Library Source
4 *
5 *    [retStr,err] = rpUnitsGetUnitsName(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] = rpUnitsGetUnitsName(unitHandle)
18/// Return the unit and exponent of the Rappture Unit represented by unitHandle.
19/**
20 * Retrieve the unit and exponent of the Rappture Units object with
21 * the handle 'unitHandle'.
22 * Return the unit and exponent as one concatinated string.
23 * Error code, err=0 on success, anything else is failure.
24 */
25
26DEFUN_DLD (rpUnitsGetUnitsName, args, ,
27"-*- texinfo -*-\n\
28[retVal,err] = rpUnitsGetUnitsName(@var{unitHandle})\n\
29\n\
30Retrieve the unit and exponent of the Rappture Units object with \n\
31the handle 'unitHandle'.\n\
32Return the unit and exponent as one concatinated string.\n\
33Error code, err=0 on success, anything else is failure.")
34{
35    static std::string who = "rpUnitsGetUnitsName";
36
37    // The list of values to return.
38    octave_value_list retval;
39    int err = 1;
40    int nargin = args.length ();
41
42    const RpUnits* myUnit = NULL;
43    int unitHandle = 0;
44    std::string retStr = "";
45
46    if (nargin == 1) {
47
48        if ( args(0).is_real_scalar() ) {
49
50            unitHandle = args(0).int_value ();
51
52            /* Call the C subroutine. */
53            if ( unitHandle >= 0 ) {
54
55                // get the original unit
56                myUnit = getObject_UnitsStr(unitHandle);
57                if (myUnit) {
58                    // get the basis
59                    retStr = myUnit->getUnitsName();
60                    // adjust error code
61                    err = 0;
62                }
63            }
64            else {
65                // invalid unitHandle
66                print_usage (who.c_str());
67            }
68        }
69        else {
70            print_usage (who.c_str());
71        }
72    }
73    else {
74        print_usage (who.c_str());
75    }
76
77    retval(0) = retStr;
78    retval(1) = err;
79    return retval;
80}
Note: See TracBrowser for help on using the repository browser.