Diff of /main/trunk/utilities/rexx/platform/windows/rexx.cpp [r7687] .. [r7688] Maximize Restore

  Switch to side-by-side view

--- a/main/trunk/utilities/rexx/platform/windows/rexx.cpp
+++ b/main/trunk/utilities/rexx/platform/windows/rexx.cpp
@@ -52,90 +52,6 @@
 #include <malloc.h>
 #include <stdio.h>                              /* needed for printf()        */
 #include <string.h>                             /* needed for strlen()        */
-
-
-/**
- * Given a condition object, extracts and returns as a whole number the subcode
- * of the condition.
- */
-inline wholenumber_t conditionSubCode(RexxCondition *condition)
-{
-    return (condition->code - (condition->rc * 1000));
-}
-
-
-/**
- * Outputs the typical condition message.  For example:
- *
- *      4 *-* say dt~number
- * Error 97 running C:\work\qTest.rex line 4:  Object method not found
- * Error 97.1:  Object "a DateTime" does not understand message "NUMBER"
- *
- * @param c          The thread context we are operating in.
- * @param condObj    The condition information object.  The object returned from
- *                   the C++ API GetConditionInfo()
- * @param condition  The RexxCondition struct.  The filled in struct from the
- *                   C++ API DecodeConditionInfo().
- *
- * @assumes  There is a condition and that condObj and condition are valid.
- */
-static void standardConditionMsg(RexxThreadContext *c, RexxDirectoryObject condObj, RexxCondition *condition)
-{
-    RexxObjectPtr list = c->SendMessage0(condObj, "TRACEBACK");
-    if ( list != NULLOBJECT )
-    {
-        RexxArrayObject a = (RexxArrayObject)c->SendMessage0(list, "ALLITEMS");
-        if ( a != NULLOBJECT )
-        {
-            size_t count = c->ArrayItems(a);
-            for ( size_t i = 1; i <= count; i++ )
-            {
-                RexxObjectPtr o = c->ArrayAt(a, i);
-                if ( o != NULLOBJECT )
-                {
-                    printf("%s\n", c->ObjectToStringValue(o));
-                }
-            }
-        }
-    }
-    printf("Error %d running %s line %d: %s\n", condition->rc, c->CString(condition->program),
-           condition->position, c->CString(condition->errortext));
-
-    printf("Error %d.%03d:  %s\n", condition->rc, conditionSubCode(condition), c->CString(condition->message));
-}
-
-
-/**
- * Given a thread context, checks for a raised condition, and prints out the
- * standard condition message if there is a condition.
- *
- * @param c      Thread context we are operating in.
- * @param clear  True if the condition should be cleared, false if it should not
- *               be cleared.
- *
- * @return True if there was a condition, otherwise false.
- */
-static bool checkForCondition(RexxThreadContext *c, bool clear)
-{
-    if ( c->CheckCondition() )
-    {
-        RexxCondition condition;
-        RexxDirectoryObject condObj = c->GetConditionInfo();
-
-        if ( condObj != NULLOBJECT )
-        {
-            c->DecodeConditionInfo(condObj, &condition);
-            standardConditionMsg(c, condObj, &condition);
-
-            if ( clear )
-            {
-                c->ClearCondition();
-            }
-            return true;
-        }
-    }
-    return false;
-}
 
 
 //
@@ -300,11 +216,18 @@
             pgmThrdInst->DirectoryPut(dir, rxcargs, "SYSCARGS");
             // call the interpreter
             result = pgmThrdInst->CallProgram(program_name, rxargs);
-            checkForCondition(pgmThrdInst, false);
-            rc = 0;
+            // display any error message if there is a condition.
+            // if there was an error, then that will be our return code
+            rc = pgmThrdInst->DisplayCondition();
+            if (rc != 0) {
+                return -rc;   // well, the negation of the error number is the return code
+            }
+            // now handle any potential return value
             if (result != NULL) {
                 pgmThrdInst->ObjectToInt32(result, &rc);
             }
+
+            return rc;
         }
     }
     return rc ? rc : rexxrc;                    // rexx program return cd