From 12bdfc054fa28362ae054d574c1e843d93c8834b Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Thu, 8 Aug 2013 00:58:18 -0400 Subject: [PATCH] More work on the NDA --- abCalcNDA.c | 28 ++++++++++++++++++++++++++-- abCalcNDA.defs | 8 +++++--- abCalcNDA.rez | 7 +++++++ ops/abCOp.c | 1 + 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/abCalcNDA.c b/abCalcNDA.c index c9f3922..6dda4c8 100644 --- a/abCalcNDA.c +++ b/abCalcNDA.c @@ -240,6 +240,20 @@ void UpdateStack(void) } +BOOLEAN ErrorRaised(void) +{ + char *errorString = abCalcGetError(); + if (errorString == NULL) { + return FALSE; + } + + AlertWindow(awCString+awResource, (Pointer)&errorString, abCalcErrorAlert); + + abCalcClearError(); + return TRUE; +} + + void PushCalcEntry(CtlRecHndl entryBox) { static Str255 strBuf; @@ -274,9 +288,12 @@ void ExecCalcCmd(char *cmd) PushCalcEntry(entryBox); - if (op != NULL) { + if ((!ErrorRaised()) && + (op != NULL)) { op->execute(); } + + ErrorRaised(); UpdateStack(); } @@ -316,7 +333,13 @@ void HandleOpClick(void) if (op != NULL) { CtlRecHndl entryBox = GetCtlHandleFromID(gCalcWinPtr, abCalcEntryBox); PushCalcEntry(entryBox); - op->execute(); + + if (!ErrorRaised()) { + op->execute(); + } + + ErrorRaised(); + UpdateStack(); } @@ -373,6 +396,7 @@ void HandleControl(EventRecord *event) case abCalcBtnEnter: PushCalcEntry(entryBox); + ErrorRaised(); UpdateStack(); break; diff --git a/abCalcNDA.defs b/abCalcNDA.defs index c3caeff..b383cc6 100644 --- a/abCalcNDA.defs +++ b/abCalcNDA.defs @@ -81,9 +81,11 @@ #define abCalcBtnPow 2047 #define abCalcBtnPowStr 2048 -#define abCalcEntryBox 2049 -#define abCalcStackList 2050 -#define abCalcOpList 2051 +#define abCalcEntryBox 3001 +#define abCalcStackList 3002 +#define abCalcOpList 3003 + +#define abCalcErrorAlert 4001 #define abCalcWinX 10 diff --git a/abCalcNDA.rez b/abCalcNDA.rez index a98afbc..7c7baa1 100644 --- a/abCalcNDA.rez +++ b/abCalcNDA.rez @@ -453,3 +453,10 @@ resource rControlTemplate (abCalcEntryBox) { 0 /* text Ref */ }}; }; + +resource rAlertString (abCalcErrorAlert) { + "23/" + "*0" + "/^#0\$00" +}; + diff --git a/ops/abCOp.c b/ops/abCOp.c index dd406ed..550895a 100644 --- a/ops/abCOp.c +++ b/ops/abCOp.c @@ -72,6 +72,7 @@ static int gNumOps = 0; void abCalcOpInit(void) { + gNumOps = 0; memset(gOps, 0, sizeof(gOps)); abCalcOpAddInit();