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 | |
---|
26 | DEFUN_DLD (rpUnitsGetUnitsName, args, , |
---|
27 | "-*- texinfo -*-\n\ |
---|
28 | [retVal,err] = rpUnitsGetUnitsName(@var{unitHandle})\n\ |
---|
29 | \n\ |
---|
30 | Retrieve the unit and exponent of the Rappture Units object with \n\ |
---|
31 | the handle 'unitHandle'.\n\ |
---|
32 | Return the unit and exponent as one concatinated string.\n\ |
---|
33 | Error 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 | } |
---|