From 306e09c6cc9de717c86afb378aff21e887a7af3f Mon Sep 17 00:00:00 2001 From: Scott R Charlton Date: Fri, 6 Jul 2012 22:55:42 +0000 Subject: [PATCH] Added GetSelectedOutputValue2 git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@6731 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- All.2005.sln | 51 +++---- IPhreeqc.2005.vcproj | 2 +- doc/Makefile | 2 + doc/examples/GetSelectedOutputValue2.c | 53 ++++++++ src/IPhreeqc.cpp | 41 ++++++ src/IPhreeqc.h | 175 ++++++++++++++++++++++++- src/IPhreeqc.hpp | 166 ++++++++++++++++++++++- src/IPhreeqcLib.cpp | 21 +++ 8 files changed, 466 insertions(+), 45 deletions(-) create mode 100644 doc/examples/GetSelectedOutputValue2.c diff --git a/All.2005.sln b/All.2005.sln index 164d8b7f..7e0f45ac 100644 --- a/All.2005.sln +++ b/All.2005.sln @@ -1,39 +1,24 @@  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IPhreeqc", "IPhreeqc.vcproj", "{F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit", "unit\unit.vcproj", "{270BB952-FCB2-4FA8-821E-BB750E83C902}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_c", "tests\test_c.vcproj", "{6F2B675D-2585-4AD6-866D-4DDA00279B00}" - ProjectSection(ProjectDependencies) = postProject - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_cxx", "tests\test_cxx.vcproj", "{3102214A-D304-48FC-B2DF-94D838DC4B2A}" - ProjectSection(ProjectDependencies) = postProject - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} - EndProjectSection EndProject Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "test_f90", "tests\test_f90.vfproj", "{003309EE-36BE-493B-87D4-FE68918DA9AF}" - ProjectSection(ProjectDependencies) = postProject - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} - EndProjectSection EndProject Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "test_f", "tests\test_f.vfproj", "{66E68C3F-EFCE-47EE-80F1-4D8F6F8AB450}" - ProjectSection(ProjectDependencies) = postProject - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} - EndProjectSection EndProject Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "memory_leak_f", "memory_leak_f\memory_leak_f.vfproj", "{941BC4D5-7D05-4786-BC65-38914514EA9B}" - ProjectSection(ProjectDependencies) = postProject - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} = {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7} - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "advect_c", "examples\c\advect\advect_c.vcproj", "{BD883425-1DD0-466A-911B-32AD6D4CE262}" EndProject Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "advect", "examples\fortran\advect\advect.vfproj", "{28459FF2-3C6C-469E-B0C3-2E4D483E7025}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IPhreeqc", "IPhreeqc.2005.vcproj", "{B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -46,22 +31,6 @@ Global ReleaseDll|x64 = ReleaseDll|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Debug|Win32.ActiveCfg = Debug|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Debug|Win32.Build.0 = Debug|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Debug|x64.ActiveCfg = Debug|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Debug|x64.Build.0 = Debug|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.DebugDll|Win32.ActiveCfg = DebugDll|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.DebugDll|Win32.Build.0 = DebugDll|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.DebugDll|x64.ActiveCfg = DebugDll|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.DebugDll|x64.Build.0 = DebugDll|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Release|Win32.ActiveCfg = Release|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Release|Win32.Build.0 = Release|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Release|x64.ActiveCfg = Release|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.Release|x64.Build.0 = Release|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.ReleaseDll|Win32.ActiveCfg = ReleaseDll|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.ReleaseDll|Win32.Build.0 = ReleaseDll|Win32 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.ReleaseDll|x64.ActiveCfg = ReleaseDll|x64 - {F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}.ReleaseDll|x64.Build.0 = ReleaseDll|x64 {270BB952-FCB2-4FA8-821E-BB750E83C902}.Debug|Win32.ActiveCfg = Debug|Win32 {270BB952-FCB2-4FA8-821E-BB750E83C902}.Debug|Win32.Build.0 = Debug|Win32 {270BB952-FCB2-4FA8-821E-BB750E83C902}.Debug|x64.ActiveCfg = Debug|x64 @@ -181,6 +150,22 @@ Global {28459FF2-3C6C-469E-B0C3-2E4D483E7025}.ReleaseDll|Win32.Build.0 = ReleaseDll|Win32 {28459FF2-3C6C-469E-B0C3-2E4D483E7025}.ReleaseDll|x64.ActiveCfg = ReleaseDll|x64 {28459FF2-3C6C-469E-B0C3-2E4D483E7025}.ReleaseDll|x64.Build.0 = ReleaseDll|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Debug|Win32.ActiveCfg = Debug|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Debug|Win32.Build.0 = Debug|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Debug|x64.ActiveCfg = Debug|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Debug|x64.Build.0 = Debug|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.DebugDll|Win32.ActiveCfg = DebugDll|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.DebugDll|Win32.Build.0 = DebugDll|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.DebugDll|x64.ActiveCfg = DebugDll|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.DebugDll|x64.Build.0 = DebugDll|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Release|Win32.ActiveCfg = Release|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Release|Win32.Build.0 = Release|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Release|x64.ActiveCfg = Release|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.Release|x64.Build.0 = Release|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.ReleaseDll|Win32.ActiveCfg = ReleaseDll|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.ReleaseDll|Win32.Build.0 = ReleaseDll|Win32 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.ReleaseDll|x64.ActiveCfg = ReleaseDll|x64 + {B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}.ReleaseDll|x64.Build.0 = ReleaseDll|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/IPhreeqc.2005.vcproj b/IPhreeqc.2005.vcproj index 60fa739b..18510322 100644 --- a/IPhreeqc.2005.vcproj +++ b/IPhreeqc.2005.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="IPhreeqc" - ProjectGUID="{F9C18E06-F73A-4EB0-92E0-AE1713EA7FD7}" + ProjectGUID="{B0A40DC6-D218-4028-9FF1-3E25EF0FF5FE}" RootNamespace="IPhreeqc" > diff --git a/doc/Makefile b/doc/Makefile index 45eb4f20..85f410c8 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -16,6 +16,8 @@ EXAMPLES = \ examples/GetOutputString.c \ examples/GetSelectedOutputString.c \ examples/GetSelectedOutputValue.c \ + examples/GetSelectedOutputValue2.c \ + examples/IPhreeqc.cpp \ examples/F90ClearAccumulatedLines.f90 \ examples/F90CreateIPhreeqc.f90 \ examples/F90DestroyIPhreeqc.f90 \ diff --git a/doc/examples/GetSelectedOutputValue2.c b/doc/examples/GetSelectedOutputValue2.c new file mode 100644 index 00000000..c98c53f7 --- /dev/null +++ b/doc/examples/GetSelectedOutputValue2.c @@ -0,0 +1,53 @@ +#include +#include +#include + +const int SVALUE_LENGTH = 100; + +int main(void) +{ + int id, i, j, vtype; + double dvalue + char svalue[SVALUE_LENGTH]; + + id = CreateIPhreeqc(); + if (id < 0) { + return EXIT_FAILURE; + } + + if (LoadDatabase(id, "phreeqc.dat") != 0) { + OutputErrorString(id); + return EXIT_FAILURE; + } + + if (RunFile(id, "ex2") != 0) { + OutputErrorString(id); + return EXIT_FAILURE; + } + + printf("selected-output:\n"); + for (i = 0; i < GetSelectedOutputRowCount(id); ++i) { + for (j = 0; j < GetSelectedOutputColumnCount(id); ++j) { + if (GetSelectedOutputValue2(id, i, j, vtype, dvalue, svalue, SVALUE_LENGTH) == VR_OK) { + switch (v.type) { + case TT_LONG: + printf("%ld ", v.lVal); + break; + case TT_DOUBLE: + printf("%g ", v.dVal); + break; + case TT_STRING: + printf("%s ", v.sVal); + break; + } + } + } + printf("\n"); + } + + if (DestroyIPhreeqc(id)) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/src/IPhreeqc.cpp b/src/IPhreeqc.cpp index e6f83cd5..2cb432db 100644 --- a/src/IPhreeqc.cpp +++ b/src/IPhreeqc.cpp @@ -1,4 +1,5 @@ #include // auto_ptr +#include #include "IPhreeqc.hpp" // IPhreeqc #include "Phreeqc.h" // Phreeqc @@ -405,6 +406,46 @@ VRESULT IPhreeqc::GetSelectedOutputValue(int row, int col, VAR* pVAR) return v; } +VRESULT IPhreeqc::GetSelectedOutputValue2(int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length) +{ + VRESULT result; + VAR v; + VarInit(&v); + char buffer[100]; + + result = this->GetSelectedOutputValue(row, col, &v); + + switch (v.type) + { + case TT_EMPTY: + *vtype = v.type; + break; + case TT_ERROR: + *vtype = v.type; + break; + case TT_LONG: + *vtype = TT_DOUBLE; + *dvalue = (double)v.lVal; + ::sprintf(buffer, "%ld", v.lVal); + ::strncpy(svalue, buffer, svalue_length); + break; + case TT_DOUBLE: + *vtype = v.type; + *dvalue = v.dVal; + ::sprintf(buffer, "%23.15e", v.dVal); + ::strncpy(svalue, buffer, svalue_length); + break; + case TT_STRING: + *vtype = v.type; + ::strncpy(svalue, v.sVal, svalue_length); + break; + default: + assert(0); + } + ::VarClear(&v); + return result; +} + const char* IPhreeqc::GetWarningString(void) { this->WarningString = ((CErrorReporter*)this->WarningReporter)->GetOS()->str(); diff --git a/src/IPhreeqc.h b/src/IPhreeqc.h index 3579a136..ea2f2a39 100644 --- a/src/IPhreeqc.h +++ b/src/IPhreeqc.h @@ -288,7 +288,7 @@ extern "C" { * Retrieves the string buffer containing DUMP output. * @param id The instance id returned from \ref CreateIPhreeqc. * @return A null terminated string containing DUMP output. - * @pre \ref SetDumpStringOn must have been set to true (non-zero) in order to recieve DUMP output. + * @pre \ref SetDumpStringOn must have been set to true (non-zero) in order to receive DUMP output. * @see GetDumpFileOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, GetDumpStringOn, SetDumpStringOn * @par Fortran90 Interface: * Not implemented. (see \ref GetDumpStringLineCount, \ref GetDumpStringLine) @@ -540,7 +540,7 @@ extern "C" { * @param id The instance id returned from \ref CreateIPhreeqc. * @return A null terminated string containing log output. * @remarks Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages. - * @pre \ref SetLogStringOn must have been set to true (non-zero) in order to recieve log output. + * @pre \ref SetLogStringOn must have been set to true (non-zero) in order to receive log output. * @see GetLogFileOn, GetLogStringLine, GetLogStringLineCount, SetLogFileOn, GetLogStringOn, SetLogStringOn * @par Fortran90 Interface: * Not implemented. (see \ref GetLogStringLineCount, \ref GetLogStringLine) @@ -667,7 +667,7 @@ extern "C" { * Retrieves the string buffer containing phreeqc output. * @param id The instance id returned from \ref CreateIPhreeqc. * @return A null terminated string containing phreeqc output. - * @pre \ref SetOutputStringOn must have been set to true (non-zero) in order to recieve phreeqc output. + * @pre \ref SetOutputStringOn must have been set to true (non-zero) in order to receive phreeqc output. * @see GetOutputFileOn, GetOutputStringLine, GetOutputStringLineCount, SetOutputFileOn, GetOutputStringOn, SetOutputStringOn * @par Fortran90 Interface: * Not implemented. (see \ref GetOutputStringLineCount, \ref GetOutputStringLine) @@ -814,7 +814,7 @@ extern "C" { * Retrieves the string buffer containing SELECTED_OUTPUT. * @param id The instance id returned from \ref CreateIPhreeqc. * @return A null terminated string containing SELECTED_OUTPUT. - * @pre \ref SetSelectedOutputStringOn must have been set to true (non-zero) in order to recieve SELECTED_OUTPUT. + * @pre \ref SetSelectedOutputStringOn must have been set to true (non-zero) in order to receive SELECTED_OUTPUT. * @see GetSelectedOutputFileOn, GetSelectedOutputStringLine, GetSelectedOutputStringLineCount, SetSelectedOutputFileOn, GetSelectedOutputStringOn, SetSelectedOutputStringOn * @par Fortran90 Interface: * Not implemented. (see \ref GetSelectedOutputStringLineCount, \ref GetSelectedOutputStringLine) @@ -924,13 +924,13 @@ extern "C" { * @param id The instance id returned from \ref CreateIPhreeqc. * @param row The row index. * @param col The column index. - * @param pVAR Pointer to the \c VAR to recieve the requested data. + * @param pVAR Pointer to the \c VAR to receive the requested data. * @retval IPQ_OK Success. * @retval IPQ_INVALIDROW The given row is out of range. * @retval IPQ_INVALIDCOL The given column is out of range. * @retval IPQ_OUTOFMEMORY Memory could not be allocated. * @retval IPQ_BADINSTANCE The given id is invalid. - * @see GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, SetSelectedOutputFileOn + * @see GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue2, SetSelectedOutputFileOn * @remarks * Row 0 contains the column headings to the selected_ouput. * @par Examples: @@ -1106,6 +1106,169 @@ Headings IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue(int id, int row, int col, VAR* pVAR); +/** + * Returns the associated data with the specified row and column. + * @param id The instance id returned from \ref CreateIPhreeqc. + * @param row The row index. + * @param col The column index. + * @param vtype Receives the variable type. See \ref VAR_TYPE. + * @param dvalue Receives the numeric value when (VTYPE=\ref TT_DOUBLE) or (VTYPE=\ref TT_LONG). + * @param svalue Receives the string variable when (VTYPE=\ref TT_STRING). When (VTYPE=\ref TT_DOUBLE) or (VTYPE=\ref TT_LONG) this variable is filled with a string equivalent of DVALUE. + * @param svalue_length The length of the svalue buffer. + * @retval IPQ_OK Success. + * @retval IPQ_INVALIDROW The given row is out of range. + * @retval IPQ_INVALIDCOL The given column is out of range. + * @retval IPQ_OUTOFMEMORY Memory could not be allocated. + * @retval IPQ_BADINSTANCE The given id is invalid. + * @see GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue, SetSelectedOutputFileOn + * @remarks + * Row 0 contains the column headings to the selected_ouput. + * @par Examples: + * The headings will include a suffix and/or prefix in order to differentiate the + * columns. + * @htmlonly +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Input + +Headings +
+
+  SELECTED_OUTPUT
+    -reset false
+    -totals Ca Na
+
+
+
+  Ca(mol/kgw)  Na(mol/kgw)
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -molalities Fe+2 Hfo_sOZn+
+
+
+
+  m_Fe+2(mol/kgw)  m_Hfo_sOZn+(mol/kgw)
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -activities H+ Ca+2
+
+
+
+  la_H+  la_Ca+2
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -equilibrium_phases Calcite Dolomite
+
+
+
+  Calcite  d_Calcite  Dolomite  d_Dolomite
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -saturation_indices CO2(g) Siderite
+
+
+
+  si_CO2(g)  si_Siderite
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -gases CO2(g) N2(g)
+
+
+
+  pressure "total mol" volume g_CO2(g) g_N2(g)
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -kinetic_reactants CH2O Pyrite
+
+
+
+  k_CH2O dk_CH2O k_Pyrite dk_Pyrite
+
+
+
+  SELECTED_OUTPUT
+    -reset false
+    -solid_solutions CaSO4 SrSO4
+
+
+
+  s_CaSO4 s_SrSO4
+
+
+ * @endhtmlonly + * \anchor GetSelectedOutputValue2_c + * @par C Example: + * \include GetSelectedOutputValue2.c + */ + IPQ_DLL_EXPORT IPQ_RESULT GetSelectedOutputValue2(int id, int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length); + + + /** * Retrieves the warning messages from the last call to \ref RunAccumulated, \ref RunFile, \ref RunString, \ref LoadDatabase, or \ref LoadDatabaseString. * @param id The instance id returned from \ref CreateIPhreeqc. diff --git a/src/IPhreeqc.hpp b/src/IPhreeqc.hpp index 6837c6ad..c1cdffa9 100644 --- a/src/IPhreeqc.hpp +++ b/src/IPhreeqc.hpp @@ -137,7 +137,7 @@ public: * Retrieves the string buffer containing DUMP output. * @return A null terminated string containing DUMP output. * @pre - * \ref SetDumpStringOn must have been set to true in order to recieve DUMP output. + * \ref SetDumpStringOn must have been set to true in order to receive DUMP output. * @see GetDumpStringLine, GetDumpFileOn, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn */ const char* GetDumpString(void)const; @@ -291,7 +291,7 @@ public: * Retrieves the string buffer containing phreeqc output. * @return A null terminated string containing phreeqc output. * @pre - * \ref SetOutputStringOn must have been set to true in order to recieve output. + * \ref SetOutputStringOn must have been set to true in order to receive output. * @see GetOutputStringLine, GetOutputFileOn, GetOutputStringLineCount, GetOutputStringOn, SetOutputFileOn, SetOutputStringOn */ const char* GetOutputString(void)const; @@ -357,7 +357,7 @@ public: * Retrieves the string buffer containing SELECTED_OUTPUT. * @return A null terminated string containing SELECTED_OUTPUT. * @pre - * \ref SetSelectedOutputStringOn must have been set to true in order to recieve SELECTED_OUTPUT. + * \ref SetSelectedOutputStringOn must have been set to true in order to receive SELECTED_OUTPUT. * @see GetSelectedOutputStringLine, GetSelectedOutputFileOn, GetSelectedOutputStringLineCount, GetSelectedOutputStringOn, SetSelectedOutputFileOn, SetSelectedOutputStringOn */ const char* GetSelectedOutputString(void)const; @@ -392,13 +392,13 @@ public: * Returns the \c VAR associated with the specified row and column. * @param row The row index. * @param col The column index. - * @param pVAR Pointer to the \c VAR to recieve the requested data. + * @param pVAR Pointer to the \c VAR to receive the requested data. * @retval VR_OK Success. * @retval VR_INVALIDROW The given row is out of range. * @retval VR_INVALIDCOL The given column is out of range. * @retval VR_OUTOFMEMORY Memory could not be allocated. * @retval VR_BADINSTANCE The given id is invalid. - * @see GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, SetSelectedOutputFileOn + * @see GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue2, SetSelectedOutputFileOn * @remarks * Row 0 contains the column headings to the selected_ouput. * @par Examples: @@ -542,6 +542,162 @@ public: */ VRESULT GetSelectedOutputValue(int row, int col, VAR* pVAR); + /** + * Returns the associated data with the specified row and column. + * @param row The row index. + * @param col The column index. + * @param vtype Receives the variable type. See \ref VAR_TYPE. + * @param dvalue Receives the numeric value when (VTYPE=\ref TT_DOUBLE) or (VTYPE=\ref TT_LONG). + * @param svalue Receives the string variable when (VTYPE=\ref TT_STRING). When (VTYPE=\ref TT_DOUBLE) or (VTYPE=\ref TT_LONG) this variable is filled with a string equivalent of DVALUE. + * @param svalue_length The length of the svalue buffer. + * @retval IPQ_OK Success. + * @retval IPQ_INVALIDROW The given row is out of range. + * @retval IPQ_INVALIDCOL The given column is out of range. + * @retval IPQ_OUTOFMEMORY Memory could not be allocated. + * @retval IPQ_BADINSTANCE The given id is invalid. + * @see GetSelectedOutputFileOn, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, GetSelectedOutputValue, SetSelectedOutputFileOn + * @remarks + * Row 0 contains the column headings to the selected_ouput. + * @par Examples: + * The headings will include a suffix and/or prefix in order to differentiate the + * columns. + * @htmlonly +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Input + + Headings +
+
+	  SELECTED_OUTPUT
+		-reset false
+		-totals Ca Na
+	
+
+
+	  Ca(mol/kgw)  Na(mol/kgw)
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-molalities Fe+2 Hfo_sOZn+
+	
+
+
+	  m_Fe+2(mol/kgw)  m_Hfo_sOZn+(mol/kgw)
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-activities H+ Ca+2
+	
+
+
+	  la_H+  la_Ca+2
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-equilibrium_phases Calcite Dolomite
+	
+
+
+	  Calcite  d_Calcite  Dolomite  d_Dolomite
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-saturation_indices CO2(g) Siderite
+	
+
+
+	  si_CO2(g)  si_Siderite
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-gases CO2(g) N2(g)
+	
+
+
+	  pressure "total mol" volume g_CO2(g) g_N2(g)
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-kinetic_reactants CH2O Pyrite
+	
+
+
+	  k_CH2O dk_CH2O k_Pyrite dk_Pyrite
+	
+
+
+	  SELECTED_OUTPUT
+		-reset false
+		-solid_solutions CaSO4 SrSO4
+	
+
+
+	  s_CaSO4 s_SrSO4
+	
+
+ */ + VRESULT GetSelectedOutputValue2(int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length); + /** * Retrieves the warning messages from the last call to \ref RunAccumulated, \ref RunFile, \ref RunString, \ref LoadDatabase, or \ref LoadDatabaseString. * @return A null terminated string containing warning messages. diff --git a/src/IPhreeqcLib.cpp b/src/IPhreeqcLib.cpp index 6d2e7594..f1ecbeb6 100644 --- a/src/IPhreeqcLib.cpp +++ b/src/IPhreeqcLib.cpp @@ -562,6 +562,27 @@ GetSelectedOutputValue(int id, int row, int col, VAR* pVAR) return IPQ_BADINSTANCE; } +IPQ_RESULT +GetSelectedOutputValue2(int id, int row, int col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length) +{ + IPhreeqc* IPhreeqcPtr = IPhreeqcLib::GetInstance(id); + if (IPhreeqcPtr) + { + switch(IPhreeqcPtr->GetSelectedOutputValue(row, col, vtype, dvalue, svalue, svalue_length)) + { + case VR_OK: return IPQ_OK; + case VR_OUTOFMEMORY: return IPQ_OUTOFMEMORY; + case VR_BADVARTYPE: return IPQ_BADVARTYPE; + case VR_INVALIDARG: return IPQ_INVALIDARG; + case VR_INVALIDROW: return IPQ_INVALIDROW; + case VR_INVALIDCOL: return IPQ_INVALIDCOL; + default: + assert(false); + } + } + return IPQ_BADINSTANCE; +} + const char* GetWarningString(int id) {