// Text of project Inspect written on 11/21/95 at 2:11 PM
// Beginning of file Inspect.t

// Before Script for "Gadget"
// Copyright  1993-1995 by Apple Computer, Inc. All Rights Reserved.


Gadget :=
    {title: "Inspector Gadget",
     viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
     viewJustify: 16,
     viewSetupFormScript:
       func()
       begin
       	local a := GetAppParams();
       	self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop, a.appAreaWidth, a.appAreaHeight);
       end,
     debug: "Gadget",
     _proto: @157
    };

exprnLabel :=
    {text: "Expression:",
     viewBounds: {left: 2, top: 18, right: 122, bottom: 34},
     debug: "exprnLabel"
     ,
     _proto: @218
    };
AddStepForm(Gadget, exprnLabel);



expression :=
    {viewBounds: {left: 2, top: 34, right: -2, bottom: 112},
     text: "self.text",
     viewJustify: 48,
     viewFlags: 158209,
     debug: "expression",
     _proto: @185
    };
AddStepForm(Gadget, expression);
StepDeclare(Gadget, expression, 'expression);



context :=
    {text: "context",
     viewBounds: {left: 10, top: 122, right: 154, bottom: 138},
     viewFormat: 337,
     viewFont: simpleFont9,
     viewJustify: 8388614,
     debug: "context",
     _proto: @218
    };
AddStepForm(Gadget, context);
StepDeclare(Gadget, context, 'context);



_view000 :=
    {text: "Eval!",
     viewBounds: {left: 180, top: 119, right: 224, bottom: 139},
     buttonClickScript:
       func()
       begin
       	// Compile the the string expression and store the
       	// code block. Later show  the result.
           context.inspectorGadget := compile(expression.text);
           SetValue(result, 'text, context:inspectorGadget());
       end,
     _proto: @226
    };
AddStepForm(Gadget, _view000);



_view001 :=
    {text: "Result:",
     viewBounds: {left: 2, top: 146, right: 122, bottom: 162},
     _proto: @218
    };
AddStepForm(Gadget, _view001);



result :=
    {viewFlags: 1,
     viewFormat: 337,
     viewLineSpacing: 20,
     viewFont: ROM_fontSystem9Bold,
     viewBounds: {left: 4, top: 163, right: -7, bottom: -79},
     viewJustify: 240,
     debug: "result",
     viewClass: 81
    };
AddStepForm(Gadget, result);
StepDeclare(Gadget, result, 'result);



mathLabel :=
    {text: "WallyMath:",
     viewBounds: {left: 2, top: 2, right: 122, bottom: 18},
     viewJustify: 8396928
     ,
     debug: "mathLabel",
     _proto: @218
    };
AddStepForm(Gadget, mathLabel);




// Before Script for "wallyMath"
nil // Copyright  1993-1995 Apple Computer Inc.  All rights reserved.


wallyMath :=
    {viewFlags: 133649,
     viewFormat: 337,
     viewLineSpacing: 16,
     viewFont: simpleFont12,
     viewBounds: {left: 3, top: 0, right: 233, bottom: 30},
     lastText: "2 + 2 =",
     xFunc:
       func()
       begin
         self.text;
       end,
     viewChangedScript:
       func(slot, view)
       begin
         if (slot = 'text) then
           if EndsWith(self.text, "=") then
           begin
             try
                 self.xfunc := Compile(SubStr(self.text, 0, StrLen(self.text) - 1));
         
             onexception |evt.ex| do  //This should actually also catch div 0 but doesn't
             begin
                local e;
                e := CurrentException();
                Print("Error compiling xFunc...");
                :SysBeep();
                self.lastText := Clone(self.text);
                return;
             end;
       
             try  
                SetValue(self, 'text, NumberStr(Clone(self:xfunc())));
             onexception |evt.ex| do
             begin
                local e;
                e := CurrentException();
                Print("Error calling xFunc...");
                :SysBeep();
             end;
       
             self.lastText := Clone(self.text);
          end;
       end,
     viewJustify: 8320,
     debug: "wallyMath",
     viewClass: 81
    };
AddStepForm(Gadget, wallyMath);




constant |layout_Inspect.t| := Gadget;
// End of file Inspect.t



