From 14e17917535604544f1b59b615601fbc97d1a7c1 Mon Sep 17 00:00:00 2001 From: Scott R Charlton Date: Tue, 23 Mar 2010 21:05:40 +0000 Subject: [PATCH] git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4184 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- IPhreeqc.cpp | 22 +++++++++++++++------- fwrap.cpp | 21 ++++++++++++++++----- fwrap2.cpp | 5 ++--- fwrap3.cpp | 5 ++--- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/IPhreeqc.cpp b/IPhreeqc.cpp index e18a50d6..5ee1c020 100644 --- a/IPhreeqc.cpp +++ b/IPhreeqc.cpp @@ -1,4 +1,5 @@ #include +#include #include "IPhreeqc.h" #include "IPhreeqc.hpp" #include "ErrorReporter.hxx" @@ -824,29 +825,36 @@ int IPhreeqc::handler(const int action, const int type, const char *err_str, con int IPhreeqc::output_handler(const int type, const char *err_str, const int stop, void *cookie, const char *format, va_list args) { - IPhreeqc* pIPhreeqc = (IPhreeqc*) cookie; + assert(cookie == this); switch (type) { case OUTPUT_ERROR: - if (pIPhreeqc) + if (this) { - std::ostringstream oss; - oss << "ERROR: " << err_str << "\n"; if (stop == STOP) { + static std::string str(200, ' '); + static std::ostringstream oss(str); + oss << "ERROR: " << err_str << "\n"; oss << "Stopping.\n"; + this->AddError(oss.str().c_str()); + } + else + { + std::ostringstream oss; + oss << "ERROR: " << err_str << "\n"; + this->AddError(oss.str().c_str()); } - pIPhreeqc->AddError(oss.str().c_str()); } break; case OUTPUT_WARNING: - if (pIPhreeqc) + if (this) { std::ostringstream oss; oss << "WARNING: " << err_str << "\n"; - pIPhreeqc->AddWarning(oss.str().c_str()); + this->AddWarning(oss.str().c_str()); } break; diff --git a/fwrap.cpp b/fwrap.cpp index eb56193b..32ba6538 100644 --- a/fwrap.cpp +++ b/fwrap.cpp @@ -222,7 +222,12 @@ RunStringF(char* input, unsigned int input_length) int GetSelectedOutputRowCountF(void) { - return ::GetSelectedOutputRowCount(); + int rows = ::GetSelectedOutputRowCount(); + if (rows > 0) + { + rows -= 1; + } + return rows; } int @@ -237,7 +242,10 @@ GetSelectedOutputValueF(int *row, int *col, int *vtype, double* dvalue, char* sv VRESULT result; VAR v; VarInit(&v); - result = ::GetSelectedOutputValue(*row, *col, &v); + char buffer[100]; + + int adjcol = *col - 1; + result = ::GetSelectedOutputValue(*row, adjcol, &v); switch (v.type) { case TT_EMPTY: @@ -249,10 +257,14 @@ GetSelectedOutputValueF(int *row, int *col, int *vtype, double* dvalue, char* sv case TT_LONG: *vtype = TT_DOUBLE; *dvalue = (double)v.lVal; + ::sprintf(buffer, "%d", v.lVal); + padfstring(svalue, buffer, svalue_length); break; case TT_DOUBLE: *vtype = v.type; *dvalue = v.dVal; + ::sprintf(buffer, "%23.15e", v.dVal); + padfstring(svalue, buffer, svalue_length); break; case TT_STRING: *vtype = v.type; @@ -391,7 +403,7 @@ void __stdcall OUTPUTLINES(void) } int __stdcall GETSELECTEDOUTPUTROWCOUNT(void) { - return GetSelectedOutputRowCountF() - 1; + return GetSelectedOutputRowCountF(); } int __stdcall GETSELECTEDOUTPUTCOLUMNCOUNT(void) { @@ -399,8 +411,7 @@ int __stdcall GETSELECTEDOUTPUTCOLUMNCOUNT(void) } int __stdcall GETSELECTEDOUTPUTVALUE(int *row, int *col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length) { - int adjcol = *col - 1; - return GetSelectedOutputValueF(row, &adjcol, vtype, dvalue, svalue, svalue_length); + return GetSelectedOutputValueF(row, col, vtype, dvalue, svalue, svalue_length); } #if defined(__cplusplus) } diff --git a/fwrap2.cpp b/fwrap2.cpp index 08fff108..0cd78a14 100644 --- a/fwrap2.cpp +++ b/fwrap2.cpp @@ -88,7 +88,7 @@ void OUTPUTLINES(void) } int GETSELECTEDOUTPUTROWCOUNT(void) { - return GetSelectedOutputRowCountF() - 1; + return GetSelectedOutputRowCountF(); } int GETSELECTEDOUTPUTCOLUMNCOUNT(void) { @@ -96,8 +96,7 @@ int GETSELECTEDOUTPUTCOLUMNCOUNT(void) } int GETSELECTEDOUTPUTVALUE(int *row, int *col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length) { - int adjcol = *col - 1; - return GetSelectedOutputValueF(row, &adjcol, vtype, dvalue, svalue, svalue_length); + return GetSelectedOutputValueF(row, col, vtype, dvalue, svalue, svalue_length); } #if defined(__cplusplus) diff --git a/fwrap3.cpp b/fwrap3.cpp index 8662f432..252295ad 100644 --- a/fwrap3.cpp +++ b/fwrap3.cpp @@ -88,7 +88,7 @@ void outputlines_(void) } int getselectedoutputrowcount_(void) { - return GetSelectedOutputRowCountF() - 1; + return GetSelectedOutputRowCountF(); } int getselectedoutputcolumncount_(void) { @@ -96,8 +96,7 @@ int getselectedoutputcolumncount_(void) } int getselectedoutputvalue_(int *row, int *col, int *vtype, double* dvalue, char* svalue, unsigned int svalue_length) { - int adjcol = *col - 1; - return GetSelectedOutputValueF(row, &adjcol, vtype, dvalue, svalue, svalue_length); + return GetSelectedOutputValueF(row, col, vtype, dvalue, svalue, svalue_length); } #if defined(__cplusplus)